Revert 248827 "android: Migrate old content readback to use asyn..."
[chromium-blink-merge.git] / chrome / common / omaha_query_params / omaha_query_params.cc
blobf68c9be26fce4a9db3288d8451425bca2fdeb62f
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/common/omaha_query_params/omaha_query_params.h"
7 #include "base/compiler_specific.h"
8 #include "base/strings/stringprintf.h"
9 #include "base/win/windows_version.h"
10 #include "chrome/common/chrome_version_info.h"
12 namespace {
14 const char kUnknown[] = "unknown";
16 // The request extra information is the OS and architecture, this helps
17 // the server select the right package to be delivered.
18 const char kOs[] =
19 #if defined(OS_MACOSX)
20 "mac";
21 #elif defined(OS_WIN)
22 "win";
23 #elif defined(OS_ANDROID)
24 "android";
25 #elif defined(OS_CHROMEOS)
26 "cros";
27 #elif defined(OS_LINUX)
28 "linux";
29 #elif defined(OS_OPENBSD)
30 "openbsd";
31 #else
32 #error "unknown os"
33 #endif
35 const char kArch[] =
36 #if defined(__amd64__) || defined(_WIN64)
37 "x64";
38 #elif defined(__i386__) || defined(_WIN32)
39 "x86";
40 #elif defined(__arm__)
41 "arm";
42 #elif defined(__mips__)
43 "mipsel";
44 #else
45 #error "unknown arch"
46 #endif
48 const char kChrome[] = "chrome";
50 const char kStable[] = "stable";
51 const char kBeta[] = "beta";
52 const char kDev[] = "dev";
53 const char kCanary[] = "canary";
55 #if defined(GOOGLE_CHROME_BUILD)
56 const char kChromeCrx[] = "chromecrx";
57 #else
58 const char kChromiumCrx[] = "chromiumcrx";
59 #endif // defined(GOOGLE_CHROME_BUILD)
61 } // namespace
63 namespace chrome {
65 // static
66 std::string OmahaQueryParams::Get(ProdId prod) {
67 return base::StringPrintf(
68 "os=%s&arch=%s&nacl_arch=%s&prod=%s&prodchannel=%s&prodversion=%s",
69 kOs,
70 kArch,
71 getNaclArch(),
72 GetProdIdString(prod),
73 GetChannelString(),
74 chrome::VersionInfo().Version().c_str());
77 // static
78 const char* OmahaQueryParams::GetProdIdString(
79 chrome::OmahaQueryParams::ProdId prod) {
80 switch (prod) {
81 case chrome::OmahaQueryParams::CHROME:
82 return kChrome;
83 break;
84 case chrome::OmahaQueryParams::CRX:
85 #if defined(GOOGLE_CHROME_BUILD)
86 return kChromeCrx;
87 #else
88 return kChromiumCrx;
89 #endif
90 break;
92 return kUnknown;
95 // static
96 const char* OmahaQueryParams::getOS() {
97 return kOs;
100 // static
101 const char* OmahaQueryParams::getArch() {
102 return kArch;
105 // static
106 const char* OmahaQueryParams::getNaclArch() {
107 #if defined(ARCH_CPU_X86_FAMILY)
108 #if defined(ARCH_CPU_X86_64)
109 return "x86-64";
110 #elif defined(OS_WIN)
111 bool x86_64 = (base::win::OSInfo::GetInstance()->wow64_status() ==
112 base::win::OSInfo::WOW64_ENABLED);
113 return x86_64 ? "x86-64" : "x86-32";
114 #else
115 return "x86-32";
116 #endif
117 #elif defined(ARCH_CPU_ARMEL)
118 return "arm";
119 #elif defined(ARCH_CPU_MIPSEL)
120 return "mips32";
121 #else
122 // NOTE: when adding new values here, please remember to update the
123 // comment in the .h file about possible return values from this function.
124 #error "You need to add support for your architecture here"
125 #endif
128 const char* OmahaQueryParams::GetChannelString() {
129 switch (chrome::VersionInfo::GetChannel()) {
130 case chrome::VersionInfo::CHANNEL_STABLE:
131 return kStable;
132 break;
133 case chrome::VersionInfo::CHANNEL_BETA:
134 return kBeta;
135 break;
136 case chrome::VersionInfo::CHANNEL_DEV:
137 return kDev;
138 break;
139 case chrome::VersionInfo::CHANNEL_CANARY:
140 return kCanary;
141 break;
142 case chrome::VersionInfo::CHANNEL_UNKNOWN:
143 return kUnknown;
144 break;
146 return kUnknown;
149 } // namespace chrome