OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/net_log/net_log_file_writer.h" | 5 #include "components/net_log/net_log_file_writer.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
15 #include "base/files/scoped_file.h" | 15 #include "base/files/scoped_file.h" |
16 #include "base/files/scoped_temp_dir.h" | 16 #include "base/files/scoped_temp_dir.h" |
17 #include "base/json/json_reader.h" | 17 #include "base/json/json_reader.h" |
18 #include "base/json/json_string_value_serializer.h" | 18 #include "base/json/json_string_value_serializer.h" |
19 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
20 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
21 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
22 #include "base/threading/thread_task_runner_handle.h" | 22 #include "base/threading/thread_task_runner_handle.h" |
23 #include "base/values.h" | 23 #include "base/values.h" |
24 #include "build/build_config.h" | 24 #include "build/build_config.h" |
25 #include "components/net_log/chrome_net_log.h" | 25 #include "components/net_log/chrome_net_log.h" |
26 #include "net/base/test_completion_callback.h" | 26 #include "net/base/test_completion_callback.h" |
27 #include "net/http/http_network_session.h" | 27 #include "net/http/http_network_session.h" |
28 #include "net/log/net_log_capture_mode.h" | 28 #include "net/log/net_log_capture_mode.h" |
29 #include "net/log/net_log_event_type.h" | 29 #include "net/log/net_log_event_type.h" |
| 30 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" |
30 #include "net/url_request/url_request_context_getter.h" | 31 #include "net/url_request/url_request_context_getter.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 | 34 |
34 namespace { | 35 namespace { |
35 | 36 |
36 const char kChannelString[] = "SomeChannel"; | 37 const char kChannelString[] = "SomeChannel"; |
37 | 38 |
38 // Keep this in sync with kLogRelativePath defined in net_log_file_writer.cc. | 39 // Keep this in sync with kLogRelativePath defined in net_log_file_writer.cc. |
39 base::FilePath::CharType kLogRelativePath[] = | 40 base::FilePath::CharType kLogRelativePath[] = |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 void SetUpTestContextGetterWithRequest( | 185 void SetUpTestContextGetterWithRequest( |
185 net::NetLog* net_log, | 186 net::NetLog* net_log, |
186 const GURL& url, | 187 const GURL& url, |
187 net::URLRequest::Delegate* delegate, | 188 net::URLRequest::Delegate* delegate, |
188 scoped_refptr<net::TestURLRequestContextGetter>* context_getter, | 189 scoped_refptr<net::TestURLRequestContextGetter>* context_getter, |
189 std::unique_ptr<net::URLRequest>* request) { | 190 std::unique_ptr<net::URLRequest>* request) { |
190 auto context = base::MakeUnique<net::TestURLRequestContext>(true); | 191 auto context = base::MakeUnique<net::TestURLRequestContext>(true); |
191 context->set_net_log(net_log); | 192 context->set_net_log(net_log); |
192 context->Init(); | 193 context->Init(); |
193 | 194 |
194 *request = context->CreateRequest(url, net::IDLE, delegate); | 195 *request = context->CreateRequest(url, net::IDLE, delegate, |
| 196 TRAFFIC_ANNOTATION_FOR_TESTS); |
195 (*request)->Start(); | 197 (*request)->Start(); |
196 | 198 |
197 *context_getter = new net::TestURLRequestContextGetter( | 199 *context_getter = new net::TestURLRequestContextGetter( |
198 base::ThreadTaskRunnerHandle::Get(), std::move(context)); | 200 base::ThreadTaskRunnerHandle::Get(), std::move(context)); |
199 } | 201 } |
200 | 202 |
201 // An implementation of NetLogFileWriter::StateObserver that allows waiting | 203 // An implementation of NetLogFileWriter::StateObserver that allows waiting |
202 // until it's notified of a new state. | 204 // until it's notified of a new state. |
203 class TestStateObserver : public NetLogFileWriter::StateObserver { | 205 class TestStateObserver : public NetLogFileWriter::StateObserver { |
204 public: | 206 public: |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 // StartNetLog() call (called by StartThenVerifyState()). | 789 // StartNetLog() call (called by StartThenVerifyState()). |
788 std::unique_ptr<base::DictionaryValue> state = | 790 std::unique_ptr<base::DictionaryValue> state = |
789 test_state_observer_.WaitForNewState(); | 791 test_state_observer_.WaitForNewState(); |
790 ASSERT_TRUE(VerifyState(std::move(state), kStateStoppingLogString)); | 792 ASSERT_TRUE(VerifyState(std::move(state), kStateStoppingLogString)); |
791 state = test_state_observer_.WaitForNewState(); | 793 state = test_state_observer_.WaitForNewState(); |
792 ASSERT_TRUE(VerifyState(std::move(state), kStateNotLoggingString, true, true, | 794 ASSERT_TRUE(VerifyState(std::move(state), kStateNotLoggingString, true, true, |
793 kCaptureModeIncludeSocketBytesString)); | 795 kCaptureModeIncludeSocketBytesString)); |
794 } | 796 } |
795 | 797 |
796 } // namespace net_log | 798 } // namespace net_log |
OLD | NEW |