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

Side by Side Diff: chrome/browser/precache/precache_util.cc

Issue 2462983003: Move data use measurement to DataUseNetworkDelegate (Closed)
Patch Set: Rebased and fixed nits Created 4 years, 1 month 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/precache/precache_util.h" 5 #include "chrome/browser/precache/precache_util.h"
6 6
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/precache/precache_manager_factory.h" 9 #include "chrome/browser/precache/precache_manager_factory.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/profiles/profile_manager.h" 11 #include "chrome/browser/profiles/profile_manager.h"
12 #include "components/data_use_measurement/content/data_use_measurement.h" 12 #include "components/data_use_measurement/content/content_url_request_classifier .h"
13 #include "components/precache/content/precache_manager.h" 13 #include "components/precache/content/precache_manager.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "net/url_request/url_request.h" 15 #include "net/url_request/url_request.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 namespace net { 18 namespace net {
19 class HttpResponseInfo; 19 class HttpResponseInfo;
20 } 20 }
21 21
22 namespace { 22 namespace {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // For better accuracy, we use the actual bytes read instead of the length 57 // For better accuracy, we use the actual bytes read instead of the length
58 // specified with the Content-Length header, which may be inaccurate, 58 // specified with the Content-Length header, which may be inaccurate,
59 // or missing, as is the case with chunked encoding. 59 // or missing, as is the case with chunked encoding.
60 int64_t received_content_length = request->received_response_content_length(); 60 int64_t received_content_length = request->received_response_content_length();
61 base::TimeDelta latency = base::TimeTicks::Now() - request->creation_time(); 61 base::TimeDelta latency = base::TimeTicks::Now() - request->creation_time();
62 62
63 // Record precache metrics when a fetch is completed successfully, if 63 // Record precache metrics when a fetch is completed successfully, if
64 // precaching is allowed. 64 // precaching is allowed.
65 content::BrowserThread::PostTask( 65 content::BrowserThread::PostTask(
66 content::BrowserThread::UI, FROM_HERE, 66 content::BrowserThread::UI, FROM_HERE,
67 base::Bind( 67 base::Bind(&UpdatePrecacheMetricsAndStateOnUIThread, request->url(),
68 &UpdatePrecacheMetricsAndStateOnUIThread, request->url(), 68 GURL(request->referrer()), latency, base::Time::Now(),
69 GURL(request->referrer()), latency, base::Time::Now(), 69 request->response_info(), received_content_length,
70 request->response_info(), received_content_length, 70 data_use_measurement::IsUserRequest(*request), profile_id));
71 data_use_measurement::DataUseMeasurement::IsUserInitiatedRequest(
72 *request),
73 profile_id));
74 } 71 }
75 72
76 } // namespace precache 73 } // namespace precache
OLDNEW
« no previous file with comments | « chrome/browser/net/chrome_network_delegate_unittest.cc ('k') | chrome/browser/profiles/profile_impl_io_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698