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 "chrome/service/net/service_url_request_context_getter.h" | 5 #include "chrome/service/net/service_url_request_context_getter.h" |
6 | 6 |
7 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 7 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
8 #include <sys/utsname.h> | 8 #include <sys/utsname.h> |
9 #endif | 9 #endif |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "base/sys_info.h" | 14 #include "base/sys_info.h" |
15 #include "chrome/common/chrome_version_info.h" | |
16 #include "chrome/service/service_process.h" | 15 #include "chrome/service/service_process.h" |
| 16 #include "components/version_info/version_info.h" |
17 #include "net/proxy/proxy_config_service.h" | 17 #include "net/proxy/proxy_config_service.h" |
18 #include "net/proxy/proxy_service.h" | 18 #include "net/proxy/proxy_service.h" |
19 #include "net/url_request/url_request_context_builder.h" | 19 #include "net/url_request/url_request_context_builder.h" |
20 | 20 |
21 namespace { | 21 namespace { |
22 // Copied from webkit/glue/user_agent.cc. We don't want to pull in a dependency | 22 // Copied from webkit/glue/user_agent.cc. We don't want to pull in a dependency |
23 // on webkit/glue which also pulls in the renderer. Also our user-agent is | 23 // on webkit/glue which also pulls in the renderer. Also our user-agent is |
24 // totally different from the user-agent used by the browser, just the | 24 // totally different from the user-agent used by the browser, just the |
25 // OS-specific parts are common. | 25 // OS-specific parts are common. |
26 std::string BuildOSCpuInfo() { | 26 std::string BuildOSCpuInfo() { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 cputype.c_str() // e.g. i686 | 72 cputype.c_str() // e.g. i686 |
73 #endif | 73 #endif |
74 ); // NOLINT | 74 ); // NOLINT |
75 | 75 |
76 return os_cpu; | 76 return os_cpu; |
77 } | 77 } |
78 | 78 |
79 // Returns the default user agent. | 79 // Returns the default user agent. |
80 std::string MakeUserAgentForServiceProcess() { | 80 std::string MakeUserAgentForServiceProcess() { |
81 std::string user_agent; | 81 std::string user_agent; |
82 chrome::VersionInfo version_info; | |
83 std::string extra_version_info; | 82 std::string extra_version_info; |
84 if (!version_info.IsOfficialBuild()) | 83 if (!version_info::IsOfficialBuild()) |
85 extra_version_info = "-devel"; | 84 extra_version_info = "-devel"; |
86 base::StringAppendF(&user_agent, | 85 base::StringAppendF(&user_agent, |
87 "Chrome Service %s(%s)%s %s ", | 86 "Chrome Service %s(%s)%s %s ", |
88 version_info.Version().c_str(), | 87 version_info::GetVersionNumber().c_str(), |
89 version_info.LastChange().c_str(), | 88 version_info::GetLastChange().c_str(), |
90 extra_version_info.c_str(), | 89 extra_version_info.c_str(), |
91 BuildOSCpuInfo().c_str()); | 90 BuildOSCpuInfo().c_str()); |
92 return user_agent; | 91 return user_agent; |
93 } | 92 } |
94 | 93 |
95 } // namespace | 94 } // namespace |
96 | 95 |
97 ServiceURLRequestContextGetter::ServiceURLRequestContextGetter() | 96 ServiceURLRequestContextGetter::ServiceURLRequestContextGetter() |
98 : user_agent_(MakeUserAgentForServiceProcess()), | 97 : user_agent_(MakeUserAgentForServiceProcess()), |
99 network_task_runner_(g_service_process->io_task_runner()) { | 98 network_task_runner_(g_service_process->io_task_runner()) { |
(...skipping 15 matching lines...) Expand all Loading... |
115 } | 114 } |
116 return url_request_context_.get(); | 115 return url_request_context_.get(); |
117 } | 116 } |
118 | 117 |
119 scoped_refptr<base::SingleThreadTaskRunner> | 118 scoped_refptr<base::SingleThreadTaskRunner> |
120 ServiceURLRequestContextGetter::GetNetworkTaskRunner() const { | 119 ServiceURLRequestContextGetter::GetNetworkTaskRunner() const { |
121 return network_task_runner_; | 120 return network_task_runner_; |
122 } | 121 } |
123 | 122 |
124 ServiceURLRequestContextGetter::~ServiceURLRequestContextGetter() {} | 123 ServiceURLRequestContextGetter::~ServiceURLRequestContextGetter() {} |
OLD | NEW |