Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: chrome/browser/component_updater/component_updater_utils.cc

Issue 74893002: Changed the update protocol for component updater from v2 to v3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed feedback from cdn@ Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/component_updater/component_updater_utils.h"
6 #include "base/guid.h"
7 #include "base/strings/stringprintf.h"
8 #include "base/sys_info.h"
9 #include "base/win/windows_version.h"
10 #include "chrome/common/chrome_version_info.h"
11 #include "chrome/common/omaha_query_params/omaha_query_params.h"
12 #include "net/base/load_flags.h"
13 #include "net/url_request/url_fetcher.h"
14 #include "net/url_request/url_request_context_getter.h"
15
16 namespace component_updater {
17
18 std::string BuildProtocolRequest(const std::string& request_body) {
19 const char request_format[] =
20 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
21 "<request protocol=\"3.0\" version=\"%s-%s\" prodversion=\"%s\" "
22 "requestid=\"{%s}\" updaterchannel=\"%s\" arch=\"%s\" nacl_arch=\"%s\">"
23 "<os platform=\"%s\" version=\"%s\" arch=\"%s\"/>"
24 "%s"
25 "</request>";
26
27 const std::string prod_id(chrome::OmahaQueryParams::GetProdIdString(
28 chrome::OmahaQueryParams::CHROME));
29 const std::string chrome_version(chrome::VersionInfo().Version().c_str());
30
31 const std::string request(base::StringPrintf(request_format,
32 // Chrome version and platform information.
33 prod_id.c_str(), chrome_version.c_str(), // "version"
34 chrome_version.c_str(), // "prodversion"
35 base::GenerateGUID().c_str(), // "requestid"
36 chrome::OmahaQueryParams::GetChannelString(), // "updaterchannel"
37 chrome::OmahaQueryParams::getArch(), // "arch"
38 chrome::OmahaQueryParams::getNaclArch(), // "nacl_arch"
39
40 // OS version and platform information.
41 chrome::VersionInfo().OSType().c_str(), // "platform"
42 base::SysInfo().OperatingSystemVersion().c_str(), // "version"
43 base::SysInfo().OperatingSystemArchitecture().c_str(), // "arch"
44
45 request_body.c_str())); // The actual payload of the request.
46
47 return request;
48 }
49
50 net::URLFetcher* SendProtocolRequest(
51 const GURL& url,
52 const std::string& protocol_request,
53 net::URLFetcherDelegate* url_fetcher_delegate,
54 net::URLRequestContextGetter* url_request_context_getter) {
55 net::URLFetcher* url_fetcher(
56 net::URLFetcher::Create(0,
57 url,
58 net::URLFetcher::POST,
59 url_fetcher_delegate));
60
61 url_fetcher->SetUploadData("application/xml", protocol_request);
62 url_fetcher->SetRequestContext(url_request_context_getter);
63 url_fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
64 net::LOAD_DO_NOT_SAVE_COOKIES |
65 net::LOAD_DISABLE_CACHE);
66 url_fetcher->SetAutomaticallyRetryOn5xx(false);
67 url_fetcher->Start();
68
69 return url_fetcher;
70 }
71
72 } // namespace component_updater
73
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698