OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/services/network/network_context.h" | 5 #include "mojo/services/network/network_context.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include <algorithm> | 10 #include <algorithm> |
8 #include <utility> | 11 #include <utility> |
9 #include <vector> | 12 #include <vector> |
10 | 13 |
11 #include "base/base_paths.h" | 14 #include "base/base_paths.h" |
12 #include "base/bind.h" | 15 #include "base/bind.h" |
13 #include "base/command_line.h" | 16 #include "base/command_line.h" |
14 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/macros.h" |
15 #include "base/path_service.h" | 19 #include "base/path_service.h" |
16 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
17 #include "mojo/common/user_agent.h" | 21 #include "mojo/common/user_agent.h" |
18 #include "mojo/services/network/mojo_persistent_cookie_store.h" | 22 #include "mojo/services/network/mojo_persistent_cookie_store.h" |
19 #include "mojo/services/network/url_loader_impl.h" | 23 #include "mojo/services/network/url_loader_impl.h" |
20 #include "net/cookies/cookie_monster.h" | 24 #include "net/cookies/cookie_monster.h" |
21 #include "net/dns/host_resolver.h" | 25 #include "net/dns/host_resolver.h" |
22 #include "net/dns/mapped_host_resolver.h" | 26 #include "net/dns/mapped_host_resolver.h" |
23 #include "net/log/net_log_util.h" | 27 #include "net/log/net_log_util.h" |
24 #include "net/log/write_to_file_net_log_observer.h" | 28 #include "net/log/write_to_file_net_log_observer.h" |
(...skipping 12 matching lines...) Expand all Loading... |
37 // Ignores certificate-related errors. | 41 // Ignores certificate-related errors. |
38 const char kIgnoreCertificateErrors[] = "ignore-certificate-errors"; | 42 const char kIgnoreCertificateErrors[] = "ignore-certificate-errors"; |
39 | 43 |
40 // Logs network information to the specified file. | 44 // Logs network information to the specified file. |
41 const char kLogNetLog[] = "log-net-log"; | 45 const char kLogNetLog[] = "log-net-log"; |
42 | 46 |
43 // Allows for forcing socket connections to HTTP/HTTPS to use fixed ports. | 47 // Allows for forcing socket connections to HTTP/HTTPS to use fixed ports. |
44 const char kTestingFixedHttpPort[] = "testing-fixed-http-port"; | 48 const char kTestingFixedHttpPort[] = "testing-fixed-http-port"; |
45 const char kTestingFixedHttpsPort[] = "testing-fixed-https-port"; | 49 const char kTestingFixedHttpsPort[] = "testing-fixed-https-port"; |
46 | 50 |
47 uint16 GetPortNumber(const base::CommandLine& command_line, | 51 uint16_t GetPortNumber(const base::CommandLine& command_line, |
48 const base::StringPiece& switch_name) { | 52 const base::StringPiece& switch_name) { |
49 std::string port_str = command_line.GetSwitchValueASCII(switch_name); | 53 std::string port_str = command_line.GetSwitchValueASCII(switch_name); |
50 unsigned port; | 54 unsigned port; |
51 if (!base::StringToUint(port_str, &port) || port > 65535) { | 55 if (!base::StringToUint(port_str, &port) || port > 65535) { |
52 LOG(ERROR) << "Invalid value for switch " << switch_name << ": '" | 56 LOG(ERROR) << "Invalid value for switch " << switch_name << ": '" |
53 << port_str << "' is not a valid port number."; | 57 << port_str << "' is not a valid port number."; |
54 return 0; | 58 return 0; |
55 } | 59 } |
56 return static_cast<uint16>(port); | 60 return static_cast<uint16_t>(port); |
57 } | 61 } |
58 | 62 |
59 } // namespace | 63 } // namespace |
60 | 64 |
61 class NetworkContext::MojoNetLog : public net::NetLog { | 65 class NetworkContext::MojoNetLog : public net::NetLog { |
62 public: | 66 public: |
63 MojoNetLog() { | 67 MojoNetLog() { |
64 const base::CommandLine* command_line = | 68 const base::CommandLine* command_line = |
65 base::CommandLine::ForCurrentProcess(); | 69 base::CommandLine::ForCurrentProcess(); |
66 if (!command_line->HasSwitch(kLogNetLog)) | 70 if (!command_line->HasSwitch(kLogNetLog)) |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 false, // TODO(erg): Make RESTORED_SESSION_COOKIES configurable. | 211 false, // TODO(erg): Make RESTORED_SESSION_COOKIES configurable. |
208 nullptr); | 212 nullptr); |
209 builder.SetCookieAndChannelIdStores( | 213 builder.SetCookieAndChannelIdStores( |
210 new net::CookieMonster(cookie_store, nullptr), nullptr); | 214 new net::CookieMonster(cookie_store, nullptr), nullptr); |
211 } | 215 } |
212 | 216 |
213 return builder.Build(); | 217 return builder.Build(); |
214 } | 218 } |
215 | 219 |
216 } // namespace mojo | 220 } // namespace mojo |
OLD | NEW |