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

Side by Side Diff: components/suggestions/suggestions_service.cc

Issue 1279543002: Support needed to measure user and service traffic in Chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@NewHistogram
Patch Set: Addressed comments and rebased. Created 5 years, 3 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 | « components/suggestions/DEPS ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/suggestions/suggestions_service.h" 5 #include "components/suggestions/suggestions_service.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
12 #include "base/metrics/sparse_histogram.h" 12 #include "base/metrics/sparse_histogram.h"
13 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "base/thread_task_runner_handle.h" 17 #include "base/thread_task_runner_handle.h"
18 #include "base/time/time.h" 18 #include "base/time/time.h"
19 #include "components/data_use_measurement/core/data_use_user_data.h"
19 #include "components/pref_registry/pref_registry_syncable.h" 20 #include "components/pref_registry/pref_registry_syncable.h"
20 #include "components/suggestions/blacklist_store.h" 21 #include "components/suggestions/blacklist_store.h"
21 #include "components/suggestions/suggestions_store.h" 22 #include "components/suggestions/suggestions_store.h"
22 #include "components/variations/net/variations_http_header_provider.h" 23 #include "components/variations/net/variations_http_header_provider.h"
23 #include "net/base/escape.h" 24 #include "net/base/escape.h"
24 #include "net/base/load_flags.h" 25 #include "net/base/load_flags.h"
25 #include "net/base/net_errors.h" 26 #include "net/base/net_errors.h"
26 #include "net/base/url_util.h" 27 #include "net/base/url_util.h"
27 #include "net/http/http_response_headers.h" 28 #include "net/http/http_response_headers.h"
28 #include "net/http/http_status_code.h" 29 #include "net/http/http_status_code.h"
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 } 257 }
257 pending_request_ = CreateSuggestionsRequest(url); 258 pending_request_ = CreateSuggestionsRequest(url);
258 pending_request_->Start(); 259 pending_request_->Start();
259 last_request_started_time_ = TimeTicks::Now(); 260 last_request_started_time_ = TimeTicks::Now();
260 } 261 }
261 262
262 scoped_ptr<net::URLFetcher> SuggestionsService::CreateSuggestionsRequest( 263 scoped_ptr<net::URLFetcher> SuggestionsService::CreateSuggestionsRequest(
263 const GURL& url) { 264 const GURL& url) {
264 scoped_ptr<net::URLFetcher> request = 265 scoped_ptr<net::URLFetcher> request =
265 net::URLFetcher::Create(0, url, net::URLFetcher::GET, this); 266 net::URLFetcher::Create(0, url, net::URLFetcher::GET, this);
267 data_use_measurement::DataUseUserData::AttachToFetcher(
268 request.get(), data_use_measurement::DataUseUserData::SUGGESTIONS);
266 request->SetLoadFlags(net::LOAD_DISABLE_CACHE); 269 request->SetLoadFlags(net::LOAD_DISABLE_CACHE);
267 request->SetRequestContext(url_request_context_); 270 request->SetRequestContext(url_request_context_);
268 // Add Chrome experiment state to the request headers. 271 // Add Chrome experiment state to the request headers.
269 net::HttpRequestHeaders headers; 272 net::HttpRequestHeaders headers;
270 variations::VariationsHttpHeaderProvider::GetInstance()->AppendHeaders( 273 variations::VariationsHttpHeaderProvider::GetInstance()->AppendHeaders(
271 request->GetOriginalURL(), false, false, &headers); 274 request->GetOriginalURL(), false, false, &headers);
272 request->SetExtraRequestHeaders(headers.ToString()); 275 request->SetExtraRequestHeaders(headers.ToString());
273 return request; 276 return request;
274 } 277 }
275 278
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 scheduling_delay_ = TimeDelta::FromSeconds(kDefaultSchedulingDelaySec); 417 scheduling_delay_ = TimeDelta::FromSeconds(kDefaultSchedulingDelaySec);
415 } else { 418 } else {
416 TimeDelta candidate_delay = 419 TimeDelta candidate_delay =
417 scheduling_delay_ * kSchedulingBackoffMultiplier; 420 scheduling_delay_ * kSchedulingBackoffMultiplier;
418 if (candidate_delay < TimeDelta::FromSeconds(kSchedulingMaxDelaySec)) 421 if (candidate_delay < TimeDelta::FromSeconds(kSchedulingMaxDelaySec))
419 scheduling_delay_ = candidate_delay; 422 scheduling_delay_ = candidate_delay;
420 } 423 }
421 } 424 }
422 425
423 } // namespace suggestions 426 } // namespace suggestions
OLDNEW
« no previous file with comments | « components/suggestions/DEPS ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698