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 #include <stdint.h> |
8 #include <sys/utsname.h> | |
9 #endif | |
10 | 8 |
11 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
12 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
13 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
14 #include "base/sys_info.h" | 12 #include "base/sys_info.h" |
| 13 #include "build/build_config.h" |
15 #include "chrome/service/service_process.h" | 14 #include "chrome/service/service_process.h" |
16 #include "components/version_info/version_info.h" | 15 #include "components/version_info/version_info.h" |
17 #include "net/proxy/proxy_config_service.h" | 16 #include "net/proxy/proxy_config_service.h" |
18 #include "net/proxy/proxy_service.h" | 17 #include "net/proxy/proxy_service.h" |
19 #include "net/url_request/url_request_context_builder.h" | 18 #include "net/url_request/url_request_context_builder.h" |
20 | 19 |
| 20 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 21 #include <sys/utsname.h> |
| 22 #endif |
| 23 |
21 namespace { | 24 namespace { |
22 // Copied from webkit/glue/user_agent.cc. We don't want to pull in a dependency | 25 // 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 | 26 // 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 | 27 // totally different from the user-agent used by the browser, just the |
25 // OS-specific parts are common. | 28 // OS-specific parts are common. |
26 std::string BuildOSCpuInfo() { | 29 std::string BuildOSCpuInfo() { |
27 std::string os_cpu; | 30 std::string os_cpu; |
28 | 31 |
29 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) | 32 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) |
30 int32 os_major_version = 0; | 33 int32_t os_major_version = 0; |
31 int32 os_minor_version = 0; | 34 int32_t os_minor_version = 0; |
32 int32 os_bugfix_version = 0; | 35 int32_t os_bugfix_version = 0; |
33 base::SysInfo::OperatingSystemVersionNumbers(&os_major_version, | 36 base::SysInfo::OperatingSystemVersionNumbers(&os_major_version, |
34 &os_minor_version, | 37 &os_minor_version, |
35 &os_bugfix_version); | 38 &os_bugfix_version); |
36 #endif | 39 #endif |
37 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 40 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
38 // Should work on any Posix system. | 41 // Should work on any Posix system. |
39 struct utsname unixinfo; | 42 struct utsname unixinfo; |
40 uname(&unixinfo); | 43 uname(&unixinfo); |
41 | 44 |
42 std::string cputype; | 45 std::string cputype; |
43 // special case for biarch systems | 46 // special case for biarch systems |
44 if (strcmp(unixinfo.machine, "x86_64") == 0 && | 47 if (strcmp(unixinfo.machine, "x86_64") == 0 && |
45 sizeof(void*) == sizeof(int32)) { // NOLINT | 48 sizeof(void*) == sizeof(int32_t)) { // NOLINT |
46 cputype.assign("i686 (x86_64)"); | 49 cputype.assign("i686 (x86_64)"); |
47 } else { | 50 } else { |
48 cputype.assign(unixinfo.machine); | 51 cputype.assign(unixinfo.machine); |
49 } | 52 } |
50 #endif | 53 #endif |
51 | 54 |
52 base::StringAppendF( | 55 base::StringAppendF( |
53 &os_cpu, | 56 &os_cpu, |
54 #if defined(OS_WIN) | 57 #if defined(OS_WIN) |
55 "Windows NT %d.%d", | 58 "Windows NT %d.%d", |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 117 } |
115 return url_request_context_.get(); | 118 return url_request_context_.get(); |
116 } | 119 } |
117 | 120 |
118 scoped_refptr<base::SingleThreadTaskRunner> | 121 scoped_refptr<base::SingleThreadTaskRunner> |
119 ServiceURLRequestContextGetter::GetNetworkTaskRunner() const { | 122 ServiceURLRequestContextGetter::GetNetworkTaskRunner() const { |
120 return network_task_runner_; | 123 return network_task_runner_; |
121 } | 124 } |
122 | 125 |
123 ServiceURLRequestContextGetter::~ServiceURLRequestContextGetter() {} | 126 ServiceURLRequestContextGetter::~ServiceURLRequestContextGetter() {} |
OLD | NEW |