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

Side by Side Diff: components/web_resource/web_resource_service.cc

Issue 2643013004: Add data usage tracking for chrome services (Closed)
Patch Set: rebased 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 | « components/web_resource/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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 #include "components/web_resource/web_resource_service.h" 5 #include "components/web_resource/web_resource_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "components/data_use_measurement/core/data_use_user_data.h"
17 #include "components/google/core/browser/google_util.h" 18 #include "components/google/core/browser/google_util.h"
18 #include "components/prefs/pref_service.h" 19 #include "components/prefs/pref_service.h"
19 #include "net/base/load_flags.h" 20 #include "net/base/load_flags.h"
20 #include "net/url_request/url_fetcher.h" 21 #include "net/url_request/url_fetcher.h"
21 #include "net/url_request/url_request_context_getter.h" 22 #include "net/url_request/url_request_context_getter.h"
22 #include "net/url_request/url_request_status.h" 23 #include "net/url_request/url_request_status.h"
23 #include "url/gurl.h" 24 #include "url/gurl.h"
24 25
25 // No anonymous namespace, because const variables automatically get internal 26 // No anonymous namespace, because const variables automatically get internal
26 // linkage. 27 // linkage.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 123
123 GURL web_resource_server = 124 GURL web_resource_server =
124 application_locale_.empty() 125 application_locale_.empty()
125 ? web_resource_server_ 126 ? web_resource_server_
126 : google_util::AppendGoogleLocaleParam(web_resource_server_, 127 : google_util::AppendGoogleLocaleParam(web_resource_server_,
127 application_locale_); 128 application_locale_);
128 129
129 DVLOG(1) << "WebResourceService StartFetch " << web_resource_server; 130 DVLOG(1) << "WebResourceService StartFetch " << web_resource_server;
130 url_fetcher_ = 131 url_fetcher_ =
131 net::URLFetcher::Create(web_resource_server, net::URLFetcher::GET, this); 132 net::URLFetcher::Create(web_resource_server, net::URLFetcher::GET, this);
133 data_use_measurement::DataUseUserData::AttachToFetcher(
134 url_fetcher_.get(),
135 data_use_measurement::DataUseUserData::WEB_RESOURCE_SERVICE);
132 // Do not let url fetcher affect existing state in system context 136 // Do not let url fetcher affect existing state in system context
133 // (by setting cookies, for example). 137 // (by setting cookies, for example).
134 url_fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE | 138 url_fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE |
135 net::LOAD_DO_NOT_SEND_COOKIES | 139 net::LOAD_DO_NOT_SEND_COOKIES |
136 net::LOAD_DO_NOT_SAVE_COOKIES); 140 net::LOAD_DO_NOT_SAVE_COOKIES);
137 url_fetcher_->SetRequestContext(request_context_.get()); 141 url_fetcher_->SetRequestContext(request_context_.get());
138 url_fetcher_->Start(); 142 url_fetcher_->Start();
139 } 143 }
140 144
141 void WebResourceService::EndFetch() { 145 void WebResourceService::EndFetch() {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // Wait at least |start_fetch_delay_ms_|. 185 // Wait at least |start_fetch_delay_ms_|.
182 if (ms_until_update > start_fetch_delay_ms_) 186 if (ms_until_update > start_fetch_delay_ms_)
183 delay = ms_until_update; 187 delay = ms_until_update;
184 } 188 }
185 } 189 }
186 // Start fetch and wait for UpdateResourceCache. 190 // Start fetch and wait for UpdateResourceCache.
187 ScheduleFetch(delay); 191 ScheduleFetch(delay);
188 } 192 }
189 193
190 } // namespace web_resource 194 } // namespace web_resource
OLDNEW
« no previous file with comments | « components/web_resource/DEPS ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698