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

Side by Side Diff: common/update_request.cc

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 months 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
« no previous file with comments | « common/update_request.h ('k') | common/update_request_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2009-2010 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 // ========================================================================
15
16 #include "omaha/common/update_request.h"
17 #include "base/scoped_ptr.h"
18 #include "omaha/base/debug.h"
19 #include "omaha/base/omaha_version.h"
20 #include "omaha/base/system_info.h"
21 #include "omaha/base/utils.h"
22 #include "omaha/common/config_manager.h"
23 #include "omaha/common/goopdate_utils.h"
24 #include "omaha/common/xml_parser.h"
25
26 namespace omaha {
27
28 namespace xml {
29
30 UpdateRequest::UpdateRequest() {
31 }
32
33 UpdateRequest::~UpdateRequest() {
34 }
35
36 // TODO(omaha): handle errors.
37 UpdateRequest* UpdateRequest::Create(bool is_machine,
38 const CString& session_id,
39 const CString& install_source,
40 const CString& origin_url) {
41 scoped_ptr<UpdateRequest> update_request(new UpdateRequest);
42
43 request::Request& request = update_request->request_;
44
45 request.is_machine = is_machine;
46 request.protocol_version = _T("3.0");
47
48 request.uid = goopdate_utils::GetUserIdLazyInit(is_machine);
49
50 request.omaha_version = GetVersionString();
51 request.install_source = install_source;
52 request.origin_url = origin_url;
53 request.test_source = ConfigManager::Instance()->GetTestSource();
54
55 GUID req_id = GUID_NULL;
56 VERIFY1(SUCCEEDED(::CoCreateGuid(&req_id)));
57 request.request_id = GuidToString(req_id);
58
59 request.session_id = session_id;
60
61 request.os.platform = kPlatformWin;
62 VERIFY1(SUCCEEDED(goopdate_utils::GetOSInfo(&request.os.version,
63 &request.os.service_pack)));
64 request.os.arch = xml::ConvertProcessorArchitectureToString(
65 SystemInfo::GetProcessorArchitecture());
66
67 bool is_period_overridden = false;
68 const int check_period_sec =
69 ConfigManager::Instance()->GetLastCheckPeriodSec(&is_period_overridden);
70 if (is_period_overridden) {
71 request.check_period_sec = check_period_sec;
72 }
73
74 return update_request.release();
75 }
76
77 void UpdateRequest::AddApp(const request::App& app) {
78 request_.apps.push_back(app);
79 }
80
81 bool UpdateRequest::has_tt_token() const {
82 for (size_t i = 0; i != request_.apps.size(); ++i) {
83 const request::App& app(request_.apps[i]);
84 if (!app.update_check.tt_token.IsEmpty()) {
85 return true;
86 }
87 }
88 return false;
89 }
90
91 HRESULT UpdateRequest::Serialize(CString* buffer) const {
92 ASSERT1(buffer);
93 return XmlParser::SerializeRequest(*this, buffer);
94 }
95
96 bool UpdateRequest::IsEmpty() const {
97 return request_.apps.empty();
98 }
99
100 } // namespace xml
101
102 } // namespace omaha
OLDNEW
« no previous file with comments | « common/update_request.h ('k') | common/update_request_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698