OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "headless/lib/browser/headless_net_log.h" | 5 #include "headless/lib/browser/headless_net_log.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 |
8 #include <utility> | 9 #include <utility> |
9 | 10 |
10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
12 #include "base/files/scoped_file.h" | 13 #include "base/files/scoped_file.h" |
| 14 #include "base/memory/ptr_util.h" |
13 #include "base/values.h" | 15 #include "base/values.h" |
14 #include "build/build_config.h" | 16 #include "build/build_config.h" |
15 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
16 #include "net/log/net_log_util.h" | 18 #include "net/log/net_log_util.h" |
17 #include "net/log/write_to_file_net_log_observer.h" | 19 #include "net/log/write_to_file_net_log_observer.h" |
18 | 20 |
19 namespace headless { | 21 namespace headless { |
20 namespace { | 22 namespace { |
21 | 23 |
22 std::unique_ptr<base::Value> GetHeadlessConstants() { | 24 std::unique_ptr<base::Value> GetHeadlessConstants() { |
23 std::unique_ptr<base::DictionaryValue> constants_dict = | 25 std::unique_ptr<base::DictionaryValue> constants_dict = |
24 net::GetNetConstants(); | 26 net::GetNetConstants(); |
25 | 27 |
26 // Add a dictionary with client information | 28 // Add a dictionary with client information |
27 base::DictionaryValue* dict = new base::DictionaryValue(); | 29 auto dict = base::MakeUnique<base::DictionaryValue>(); |
28 | 30 |
29 dict->SetString("name", "headless"); | 31 dict->SetString("name", "headless"); |
30 dict->SetString( | 32 dict->SetString( |
31 "command_line", | 33 "command_line", |
32 base::CommandLine::ForCurrentProcess()->GetCommandLineString()); | 34 base::CommandLine::ForCurrentProcess()->GetCommandLineString()); |
33 | 35 |
34 constants_dict->Set("clientInfo", dict); | 36 constants_dict->Set("clientInfo", std::move(dict)); |
35 | 37 |
36 return std::move(constants_dict); | 38 return std::move(constants_dict); |
37 } | 39 } |
38 | 40 |
39 } // namespace | 41 } // namespace |
40 | 42 |
41 HeadlessNetLog::HeadlessNetLog(const base::FilePath& log_path) { | 43 HeadlessNetLog::HeadlessNetLog(const base::FilePath& log_path) { |
42 // TODO(mmenke): Other than a different set of constants, this code is | 44 // TODO(mmenke): Other than a different set of constants, this code is |
43 // identical to code in ChromeNetLog. Consider merging the code. | 45 // identical to code in ChromeNetLog. Consider merging the code. |
44 | 46 |
(...skipping 21 matching lines...) Expand all Loading... |
66 } | 68 } |
67 } | 69 } |
68 | 70 |
69 HeadlessNetLog::~HeadlessNetLog() { | 71 HeadlessNetLog::~HeadlessNetLog() { |
70 // Remove the observer we own before we're destroyed. | 72 // Remove the observer we own before we're destroyed. |
71 if (write_to_file_observer_) | 73 if (write_to_file_observer_) |
72 write_to_file_observer_->StopObserving(nullptr); | 74 write_to_file_observer_->StopObserving(nullptr); |
73 } | 75 } |
74 | 76 |
75 } // namespace headless | 77 } // namespace headless |
OLD | NEW |