| OLD | NEW |
| (Empty) |
| 1 // Copyright 2011 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/goopdate/download_complete_ping_event.h" | |
| 17 #include "omaha/base/string.h" | |
| 18 #include "omaha/base/xml_utils.h" | |
| 19 #include "omaha/common/xml_const.h" | |
| 20 | |
| 21 namespace omaha { | |
| 22 | |
| 23 DownloadCompletePingEvent::DownloadCompletePingEvent( | |
| 24 Types type, | |
| 25 Results result, | |
| 26 int error_code, | |
| 27 int extra_code1, | |
| 28 int download_time_ms, | |
| 29 uint64 num_bytes_downloaded, | |
| 30 uint64 app_size) | |
| 31 : PingEvent(type, result, error_code, extra_code1), | |
| 32 download_time_ms_(download_time_ms), | |
| 33 num_bytes_downloaded_(num_bytes_downloaded), | |
| 34 app_size_(app_size) { | |
| 35 } | |
| 36 | |
| 37 HRESULT DownloadCompletePingEvent::ToXml(IXMLDOMNode* parent_node) const { | |
| 38 HRESULT hr = PingEvent::ToXml(parent_node); | |
| 39 if (FAILED(hr)) { | |
| 40 return hr; | |
| 41 } | |
| 42 | |
| 43 // No need to report download metrics if nothing is downloaded. | |
| 44 if (num_bytes_downloaded_ == 0) { | |
| 45 return S_OK; | |
| 46 } | |
| 47 | |
| 48 hr = AddXMLAttributeNode(parent_node, | |
| 49 xml::kXmlNamespace, | |
| 50 xml::attribute::kDownloadTime, | |
| 51 itostr(download_time_ms_)); | |
| 52 if (FAILED(hr)) { | |
| 53 return hr; | |
| 54 } | |
| 55 | |
| 56 hr = AddXMLAttributeNode(parent_node, | |
| 57 xml::kXmlNamespace, | |
| 58 xml::attribute::kAppBytesDownloaded, | |
| 59 String_Uint64ToString(num_bytes_downloaded_, 10)); | |
| 60 if (FAILED(hr)) { | |
| 61 return hr; | |
| 62 } | |
| 63 | |
| 64 return AddXMLAttributeNode(parent_node, | |
| 65 xml::kXmlNamespace, | |
| 66 xml::attribute::kAppBytesTotal, | |
| 67 String_Uint64ToString(app_size_, 10)); | |
| 68 } | |
| 69 | |
| 70 CString DownloadCompletePingEvent::ToString() const { | |
| 71 CString ping_str; | |
| 72 ping_str.Format(_T("%s, %s=%s, %s=%s, %s=%s"), | |
| 73 PingEvent::ToString(), | |
| 74 xml::attribute::kDownloadTime, itostr(download_time_ms_), | |
| 75 xml::attribute::kAppBytesDownloaded, | |
| 76 String_Uint64ToString(num_bytes_downloaded_, 10), | |
| 77 xml::attribute::kAppBytesTotal, String_Uint64ToString(app_size_, 10)); | |
| 78 | |
| 79 return ping_str; | |
| 80 } | |
| 81 | |
| 82 } // namespace omaha | |
| 83 | |
| OLD | NEW |