OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "content/shell/browser/shell_net_log.h" | 5 #include "content/shell/browser/shell_net_log.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
13 #include "net/base/net_log_logger.h" | 13 #include "net/base/net_log_logger.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 base::DictionaryValue* GetShellConstants(const std::string& app_name) { | 19 base::DictionaryValue* GetShellConstants(const std::string& app_name) { |
20 base::DictionaryValue* constants_dict = net::NetLogLogger::GetConstants(); | 20 base::DictionaryValue* constants_dict = net::NetLogLogger::GetConstants(); |
21 | 21 |
22 // Add a dictionary with client information | 22 // Add a dictionary with client information |
23 base::DictionaryValue* dict = new base::DictionaryValue(); | 23 base::DictionaryValue* dict = new base::DictionaryValue(); |
24 | 24 |
25 dict->SetString("name", app_name); | 25 dict->SetString("name", app_name); |
26 dict->SetString("command_line", | 26 dict->SetString( |
27 CommandLine::ForCurrentProcess()->GetCommandLineString()); | 27 "command_line", |
| 28 base::CommandLine::ForCurrentProcess()->GetCommandLineString()); |
28 | 29 |
29 constants_dict->Set("clientInfo", dict); | 30 constants_dict->Set("clientInfo", dict); |
30 | 31 |
31 return constants_dict; | 32 return constants_dict; |
32 } | 33 } |
33 | 34 |
34 } // namespace | 35 } // namespace |
35 | 36 |
36 ShellNetLog::ShellNetLog(const std::string& app_name) { | 37 ShellNetLog::ShellNetLog(const std::string& app_name) { |
37 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 38 const base::CommandLine* command_line = |
| 39 base::CommandLine::ForCurrentProcess(); |
38 | 40 |
39 if (command_line->HasSwitch(switches::kLogNetLog)) { | 41 if (command_line->HasSwitch(switches::kLogNetLog)) { |
40 base::FilePath log_path = | 42 base::FilePath log_path = |
41 command_line->GetSwitchValuePath(switches::kLogNetLog); | 43 command_line->GetSwitchValuePath(switches::kLogNetLog); |
42 // Much like logging.h, bypass threading restrictions by using fopen | 44 // Much like logging.h, bypass threading restrictions by using fopen |
43 // directly. Have to write on a thread that's shutdown to handle events on | 45 // directly. Have to write on a thread that's shutdown to handle events on |
44 // shutdown properly, and posting events to another thread as they occur | 46 // shutdown properly, and posting events to another thread as they occur |
45 // would result in an unbounded buffer size, so not much can be gained by | 47 // would result in an unbounded buffer size, so not much can be gained by |
46 // doing this on another thread. It's only used when debugging, so | 48 // doing this on another thread. It's only used when debugging, so |
47 // performance is not a big concern. | 49 // performance is not a big concern. |
(...skipping 15 matching lines...) Expand all Loading... |
63 } | 65 } |
64 } | 66 } |
65 | 67 |
66 ShellNetLog::~ShellNetLog() { | 68 ShellNetLog::~ShellNetLog() { |
67 // Remove the observer we own before we're destroyed. | 69 // Remove the observer we own before we're destroyed. |
68 if (net_log_logger_) | 70 if (net_log_logger_) |
69 RemoveThreadSafeObserver(net_log_logger_.get()); | 71 RemoveThreadSafeObserver(net_log_logger_.get()); |
70 } | 72 } |
71 | 73 |
72 } // namespace content | 74 } // namespace content |
OLD | NEW |