OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/data_usage/tab_id_annotator.h" | 5 #include "chrome/browser/data_usage/tab_id_annotator.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/location.h" | 15 #include "base/location.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
19 #include "chrome/browser/sessions/session_tab_helper.h" | 19 #include "chrome/browser/sessions/session_tab_helper.h" |
20 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 20 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
21 #include "components/data_usage/core/data_use.h" | 21 #include "components/data_usage/core/data_use.h" |
22 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
23 #include "content/public/browser/render_frame_host.h" | 23 #include "content/public/browser/render_frame_host.h" |
24 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
25 #include "content/public/browser/resource_request_info.h" | 25 #include "content/public/browser/resource_request_info.h" |
26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
27 #include "content/public/common/previews_state.h" | 27 #include "content/public/common/previews_state.h" |
28 #include "net/base/network_change_notifier.h" | 28 #include "net/base/network_change_notifier.h" |
29 #include "net/base/request_priority.h" | 29 #include "net/base/request_priority.h" |
| 30 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" |
30 #include "net/url_request/url_request.h" | 31 #include "net/url_request/url_request.h" |
31 #include "net/url_request/url_request_test_util.h" | 32 #include "net/url_request/url_request_test_util.h" |
32 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
33 #include "url/gurl.h" | 34 #include "url/gurl.h" |
34 | 35 |
35 using content::BrowserThread; | 36 using content::BrowserThread; |
36 using data_usage::DataUse; | 37 using data_usage::DataUse; |
37 | 38 |
38 namespace chrome_browser_data_usage { | 39 namespace chrome_browser_data_usage { |
39 | 40 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 int render_process_id, | 93 int render_process_id, |
93 int render_frame_id, | 94 int render_frame_id, |
94 int32_t expected_tab_id) { | 95 int32_t expected_tab_id) { |
95 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 96 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
96 DCHECK(ui_run_loop); | 97 DCHECK(ui_run_loop); |
97 | 98 |
98 TabIdAnnotator annotator; | 99 TabIdAnnotator annotator; |
99 net::TestURLRequestContext context; | 100 net::TestURLRequestContext context; |
100 net::TestDelegate test_delegate; | 101 net::TestDelegate test_delegate; |
101 std::unique_ptr<net::URLRequest> request = | 102 std::unique_ptr<net::URLRequest> request = |
102 context.CreateRequest(GURL("http://foo.com"), net::IDLE, &test_delegate); | 103 context.CreateRequest(GURL("http://foo.com"), net::IDLE, &test_delegate, |
| 104 TRAFFIC_ANNOTATION_FOR_TESTS); |
103 | 105 |
104 if (render_process_id != -1 && render_frame_id != -1) { | 106 if (render_process_id != -1 && render_frame_id != -1) { |
105 // The only args that matter here for the ResourceRequestInfo are the | 107 // The only args that matter here for the ResourceRequestInfo are the |
106 // |request|, the |render_process_id|, and the |render_frame_id|; arbitrary | 108 // |request|, the |render_process_id|, and the |render_frame_id|; arbitrary |
107 // values are used for all the other args. | 109 // values are used for all the other args. |
108 content::ResourceRequestInfo::AllocateForTesting( | 110 content::ResourceRequestInfo::AllocateForTesting( |
109 request.get(), content::RESOURCE_TYPE_MAIN_FRAME, nullptr, | 111 request.get(), content::RESOURCE_TYPE_MAIN_FRAME, nullptr, |
110 render_process_id, -1, render_frame_id, true, false, true, true, | 112 render_process_id, -1, render_frame_id, true, false, true, true, |
111 content::PREVIEWS_OFF); | 113 content::PREVIEWS_OFF); |
112 } | 114 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 base::Bind(&TestAnnotateOnIOThread, &ui_run_loop, | 170 base::Bind(&TestAnnotateOnIOThread, &ui_run_loop, |
169 web_contents()->GetMainFrame()->GetProcess()->GetID(), | 171 web_contents()->GetMainFrame()->GetProcess()->GetID(), |
170 web_contents()->GetMainFrame()->GetRoutingID(), | 172 web_contents()->GetMainFrame()->GetRoutingID(), |
171 expected_tab_id)); | 173 expected_tab_id)); |
172 ui_run_loop.Run(); | 174 ui_run_loop.Run(); |
173 } | 175 } |
174 | 176 |
175 } // namespace | 177 } // namespace |
176 | 178 |
177 } // namespace chrome_browser_data_usage | 179 } // namespace chrome_browser_data_usage |
OLD | NEW |