Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(380)

Side by Side Diff: components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.cc

Issue 2695883003: Change uses of base::JoinString to pass StringPieces where possible. (Closed)
Patch Set: Remove dependency CL. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_event _store.h" 5 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_event _store.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_piece.h"
15 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
16 #include "base/time/time.h" 17 #include "base/time/time.h"
17 #include "base/values.h" 18 #include "base/values.h"
18 19
19 namespace { 20 namespace {
20 21
21 const size_t kMaxEventsToStore = 100; 22 const size_t kMaxEventsToStore = 100;
22 23
23 // Used by Data Reduction Proxy feedback reports. If the last bypass happened in 24 // Used by Data Reduction Proxy feedback reports. If the last bypass happened in
24 // the last 5 minutes, the url will be cropped to only the host. 25 // the last 5 minutes, the url will be cropped to only the host.
(...skipping 19 matching lines...) Expand all
44 // without having to keep an enum map in sync. 45 // without having to keep an enum map in sync.
45 const StringToConstant kDataReductionProxyBypassActionTypeTable[] = { 46 const StringToConstant kDataReductionProxyBypassActionTypeTable[] = {
46 #define BYPASS_ACTION_TYPE(label, value) \ 47 #define BYPASS_ACTION_TYPE(label, value) \
47 { #label, data_reduction_proxy::BYPASS_ACTION_TYPE_##label } \ 48 { #label, data_reduction_proxy::BYPASS_ACTION_TYPE_##label } \
48 , 49 ,
49 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_bypas s_action_list.h" 50 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_bypas s_action_list.h"
50 #undef BYPASS_ACTION_TYPE 51 #undef BYPASS_ACTION_TYPE
51 }; 52 };
52 53
53 std::string JoinListValueStrings(base::ListValue* list_value) { 54 std::string JoinListValueStrings(base::ListValue* list_value) {
54 std::vector<std::string> values; 55 std::vector<base::StringPiece> values;
55 for (const auto& value : *list_value) { 56 for (const auto& value : *list_value) {
56 std::string value_string; 57 base::StringPiece value_string;
57 if (!value->GetAsString(&value_string)) 58 if (!value->GetAsString(&value_string))
58 return std::string(); 59 return std::string();
59 60
60 values.push_back(std::move(value_string)); 61 values.push_back(value_string);
61 } 62 }
62 63
63 return base::JoinString(values, ";"); 64 return base::JoinString(values, ";");
64 } 65 }
65 66
66 } // namespace 67 } // namespace
67 68
68 namespace data_reduction_proxy { 69 namespace data_reduction_proxy {
69 70
70 // static 71 // static
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 last_bypass->SetString("url", clean_url.spec()); 268 last_bypass->SetString("url", clean_url.spec());
268 } 269 }
269 } 270 }
270 271
271 std::string json; 272 std::string json;
272 base::JSONWriter::Write(*last_bypass.get(), &json); 273 base::JSONWriter::Write(*last_bypass.get(), &json);
273 return json; 274 return json;
274 } 275 }
275 276
276 } // namespace data_reduction_proxy 277 } // namespace data_reduction_proxy
OLDNEW
« no previous file with comments | « components/autofill/core/browser/webdata/autofill_wallet_syncable_service.cc ('k') | components/flags_ui/flags_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698