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

Side by Side Diff: chrome/browser/net/chrome_network_delegate_unittest.cc

Issue 1421983002: Include tab IDs when reporting data use accounting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@data_use_scoped_vector
Patch Set: Fixed external_data_use_observer test Created 5 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
« no previous file with comments | « chrome/browser/net/chrome_network_delegate.cc ('k') | chrome/chrome_browser.gypi » ('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 (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 #include "chrome/browser/net/chrome_network_delegate.h" 5 #include "chrome/browser/net/chrome_network_delegate.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/prefs/pref_member.h" 13 #include "base/prefs/pref_member.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/test/histogram_tester.h" 15 #include "base/test/histogram_tester.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/content_settings/cookie_settings_factory.h" 17 #include "chrome/browser/content_settings/cookie_settings_factory.h"
18 #include "chrome/browser/net/safe_search_util.h" 18 #include "chrome/browser/net/safe_search_util.h"
19 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
20 #include "chrome/test/base/testing_browser_process.h" 20 #include "chrome/test/base/testing_browser_process.h"
21 #include "chrome/test/base/testing_profile.h" 21 #include "chrome/test/base/testing_profile.h"
22 #include "chrome/test/base/testing_profile_manager.h" 22 #include "chrome/test/base/testing_profile_manager.h"
23 #include "components/content_settings/core/browser/cookie_settings.h" 23 #include "components/content_settings/core/browser/cookie_settings.h"
24 #include "components/content_settings/core/common/pref_names.h" 24 #include "components/content_settings/core/common/pref_names.h"
25 #include "components/data_usage/core/data_use_aggregator.h" 25 #include "components/data_usage/core/data_use_aggregator.h"
26 #include "components/data_usage/core/data_use_annotator.h"
26 #include "components/syncable_prefs/testing_pref_service_syncable.h" 27 #include "components/syncable_prefs/testing_pref_service_syncable.h"
27 #include "content/public/browser/resource_request_info.h" 28 #include "content/public/browser/resource_request_info.h"
28 #include "content/public/common/content_switches.h" 29 #include "content/public/common/content_switches.h"
29 #include "content/public/common/resource_type.h" 30 #include "content/public/common/resource_type.h"
30 #include "content/public/test/test_browser_thread_bundle.h" 31 #include "content/public/test/test_browser_thread_bundle.h"
31 #include "net/base/request_priority.h" 32 #include "net/base/request_priority.h"
32 #include "net/socket/socket_test_util.h" 33 #include "net/socket/socket_test_util.h"
33 #include "net/url_request/url_request.h" 34 #include "net/url_request/url_request.h"
34 #include "net/url_request/url_request_test_util.h" 35 #include "net/url_request/url_request_test_util.h"
35 #include "testing/gtest/include/gtest/gtest.h" 36 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 request->Start(); 93 request->Start();
93 base::RunLoop().RunUntilIdle(); 94 base::RunLoop().RunUntilIdle();
94 return request.Pass(); 95 return request.Pass();
95 } 96 }
96 97
97 // A fake DataUseAggregator for testing that only counts how many times its 98 // A fake DataUseAggregator for testing that only counts how many times its
98 // respective methods have been called. 99 // respective methods have been called.
99 class FakeDataUseAggregator : public data_usage::DataUseAggregator { 100 class FakeDataUseAggregator : public data_usage::DataUseAggregator {
100 public: 101 public:
101 FakeDataUseAggregator() 102 FakeDataUseAggregator()
102 : on_the_record_tx_bytes_(0), 103 : data_usage::DataUseAggregator(
104 scoped_ptr<data_usage::DataUseAnnotator>()),
105 on_the_record_tx_bytes_(0),
103 on_the_record_rx_bytes_(0), 106 on_the_record_rx_bytes_(0),
104 off_the_record_tx_bytes_(0), 107 off_the_record_tx_bytes_(0),
105 off_the_record_rx_bytes_(0) {} 108 off_the_record_rx_bytes_(0) {}
106 ~FakeDataUseAggregator() override {} 109 ~FakeDataUseAggregator() override {}
107 110
108 void ReportDataUse(const net::URLRequest& request, 111 void ReportDataUse(net::URLRequest* request,
109 int32_t tab_id,
110 int64_t tx_bytes, 112 int64_t tx_bytes,
111 int64_t rx_bytes) override { 113 int64_t rx_bytes) override {
112 on_the_record_tx_bytes_ += tx_bytes; 114 on_the_record_tx_bytes_ += tx_bytes;
113 on_the_record_rx_bytes_ += rx_bytes; 115 on_the_record_rx_bytes_ += rx_bytes;
114 } 116 }
115 117
116 void ReportOffTheRecordDataUse(int64_t tx_bytes, int64_t rx_bytes) override { 118 void ReportOffTheRecordDataUse(int64_t tx_bytes, int64_t rx_bytes) override {
117 off_the_record_tx_bytes_ += tx_bytes; 119 off_the_record_tx_bytes_ += tx_bytes;
118 off_the_record_rx_bytes_ += rx_bytes; 120 off_the_record_rx_bytes_ += rx_bytes;
119 } 121 }
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 kBlockedFirstPartySite)); 532 kBlockedFirstPartySite));
531 533
532 cookie_settings_->SetCookieSetting( 534 cookie_settings_->SetCookieSetting(
533 ContentSettingsPattern::FromURL(kBlockedFirstPartySite), 535 ContentSettingsPattern::FromURL(kBlockedFirstPartySite),
534 ContentSettingsPattern::Wildcard(), 536 ContentSettingsPattern::Wildcard(),
535 CONTENT_SETTING_BLOCK); 537 CONTENT_SETTING_BLOCK);
536 // Privacy mode is disabled as kAllowedSite is still getting cookies 538 // Privacy mode is disabled as kAllowedSite is still getting cookies
537 EXPECT_FALSE(network_delegate_->CanEnablePrivacyMode(kAllowedSite, 539 EXPECT_FALSE(network_delegate_->CanEnablePrivacyMode(kAllowedSite,
538 kBlockedFirstPartySite)); 540 kBlockedFirstPartySite));
539 } 541 }
OLDNEW
« no previous file with comments | « chrome/browser/net/chrome_network_delegate.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698