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

Side by Side Diff: components/rlz/rlz_tracker.cc

Issue 2621843002: rlz: get rid of the call to AppendHeaderIfMissing() (Closed)
Patch Set: compile Created 3 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This code glues the RLZ library DLL with Chrome. It allows Chrome to work 5 // This code glues the RLZ library DLL with Chrome. It allows Chrome to work
6 // with or without the DLL being present. If the DLL is not present the 6 // with or without the DLL being present. If the DLL is not present the
7 // functions do nothing and just return false. 7 // functions do nothing and just return false.
8 8
9 #include "components/rlz/rlz_tracker.h" 9 #include "components/rlz/rlz_tracker.h"
10 10
11 #include <algorithm> 11 #include <algorithm>
12 #include <utility> 12 #include <utility>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/strings/stringprintf.h"
17 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
18 #include "base/trace_event/trace_event.h" 19 #include "base/trace_event/trace_event.h"
19 #include "build/build_config.h" 20 #include "build/build_config.h"
20 #include "components/rlz/rlz_tracker_delegate.h" 21 #include "components/rlz/rlz_tracker_delegate.h"
21 #include "net/http/http_util.h"
22 22
23 namespace rlz { 23 namespace rlz {
24 namespace { 24 namespace {
25 25
26 // Maximum and minimum delay for financial ping we would allow to be set through 26 // Maximum and minimum delay for financial ping we would allow to be set through
27 // master preferences. Somewhat arbitrary, may need to be adjusted in future. 27 // master preferences. Somewhat arbitrary, may need to be adjusted in future.
28 const base::TimeDelta kMaxInitDelay = base::TimeDelta::FromSeconds(200); 28 const base::TimeDelta kMaxInitDelay = base::TimeDelta::FromSeconds(200);
29 const base::TimeDelta kMinInitDelay = base::TimeDelta::FromSeconds(20); 29 const base::TimeDelta kMinInitDelay = base::TimeDelta::FromSeconds(20);
30 30
31 void RecordProductEvents(bool first_run, 31 void RecordProductEvents(bool first_run,
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 return nullptr; 436 return nullptr;
437 } 437 }
438 438
439 // static 439 // static
440 std::string RLZTracker::GetAccessPointHttpHeader(rlz_lib::AccessPoint point) { 440 std::string RLZTracker::GetAccessPointHttpHeader(rlz_lib::AccessPoint point) {
441 TRACE_EVENT0("RLZ", "RLZTracker::GetAccessPointHttpHeader"); 441 TRACE_EVENT0("RLZ", "RLZTracker::GetAccessPointHttpHeader");
442 std::string extra_headers; 442 std::string extra_headers;
443 base::string16 rlz_string; 443 base::string16 rlz_string;
444 RLZTracker::GetAccessPointRlz(point, &rlz_string); 444 RLZTracker::GetAccessPointRlz(point, &rlz_string);
445 if (!rlz_string.empty()) { 445 if (!rlz_string.empty()) {
446 net::HttpUtil::AppendHeaderIfMissing("X-Rlz-String", 446 return base::StringPrintf("X-Rlz-String: %s\r\n",
447 base::UTF16ToUTF8(rlz_string), 447 base::UTF16ToUTF8(rlz_string).c_str());
448 &extra_headers);
449 } 448 }
450 449
451 return extra_headers; 450 return extra_headers;
452 } 451 }
453 452
454 // GetAccessPointRlz() caches RLZ strings for all access points. If we had 453 // GetAccessPointRlz() caches RLZ strings for all access points. If we had
455 // a successful ping, then we update the cached value. 454 // a successful ping, then we update the cached value.
456 // static 455 // static
457 bool RLZTracker::GetAccessPointRlz(rlz_lib::AccessPoint point, 456 bool RLZTracker::GetAccessPointRlz(rlz_lib::AccessPoint point,
458 base::string16* rlz) { 457 base::string16* rlz) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 // This method is called during unit tests while the RLZTracker has not been 557 // This method is called during unit tests while the RLZTracker has not been
559 // initialized, so check for the presence of a delegate and exit if there is 558 // initialized, so check for the presence of a delegate and exit if there is
560 // none registered. 559 // none registered.
561 RLZTracker* tracker = GetInstance(); 560 RLZTracker* tracker = GetInstance();
562 if (tracker->delegate_) 561 if (tracker->delegate_)
563 tracker->RecordFirstSearch(RLZTracker::ChromeAppList()); 562 tracker->RecordFirstSearch(RLZTracker::ChromeAppList());
564 } 563 }
565 #endif 564 #endif
566 565
567 } // namespace rlz 566 } // namespace rlz
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698