OLD | NEW |
| (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_response.h" | |
17 #include "omaha/base/utils.h" | |
18 #include "omaha/common/xml_parser.h" | |
19 | |
20 namespace omaha { | |
21 | |
22 namespace xml { | |
23 | |
24 UpdateResponse::UpdateResponse() { | |
25 } | |
26 | |
27 UpdateResponse::~UpdateResponse() { | |
28 } | |
29 | |
30 UpdateResponse* UpdateResponse::Create() { | |
31 return new UpdateResponse; | |
32 } | |
33 | |
34 HRESULT UpdateResponse::Deserialize(const std::vector<uint8>& buffer) { | |
35 return XmlParser::DeserializeResponse(buffer, this); | |
36 } | |
37 | |
38 HRESULT UpdateResponse::DeserializeFromFile(const CString& filename) { | |
39 std::vector<uint8> buffer; | |
40 HRESULT hr = ReadEntireFile(filename, 0, &buffer); | |
41 if (FAILED(hr)) { | |
42 return hr; | |
43 } | |
44 | |
45 ASSERT1(!buffer.empty()); | |
46 return Deserialize(buffer); | |
47 } | |
48 | |
49 int UpdateResponse::GetElapsedSecondsSinceDayStart() const { | |
50 return response_.day_start.elapsed_seconds; | |
51 } | |
52 | |
53 // Sets update_response's response_ member to response. Used by unit tests to | |
54 // set the response without needing to craft corresponding XML. UpdateResponse | |
55 // friends this function, allowing it to access the private member. | |
56 void SetResponseForUnitTest(UpdateResponse* update_response, | |
57 const response::Response& response) { | |
58 ASSERT1(update_response); | |
59 update_response->response_ = response; | |
60 } | |
61 | |
62 } // namespace xml | |
63 | |
64 } // namespace omaha | |
OLD | NEW |