OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/component_updater/component_updater_utils.h" | 5 #include "chrome/browser/component_updater/component_updater_utils.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/guid.h" | 8 #include "base/guid.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
11 #include "base/win/windows_version.h" | 11 #include "base/win/windows_version.h" |
| 12 #include "chrome/browser/component_updater/crx_update_item.h" |
12 #include "chrome/common/chrome_version_info.h" | 13 #include "chrome/common/chrome_version_info.h" |
13 #include "chrome/common/omaha_query_params/omaha_query_params.h" | 14 #include "chrome/common/omaha_query_params/omaha_query_params.h" |
14 #include "net/base/load_flags.h" | 15 #include "net/base/load_flags.h" |
15 #include "net/url_request/url_fetcher.h" | 16 #include "net/url_request/url_fetcher.h" |
16 #include "net/url_request/url_request_context_getter.h" | 17 #include "net/url_request/url_request_context_getter.h" |
17 #include "net/url_request/url_request_status.h" | 18 #include "net/url_request/url_request_status.h" |
18 | 19 |
19 namespace component_updater { | 20 namespace component_updater { |
20 | 21 |
21 std::string BuildProtocolRequest(const std::string& request_body, | 22 std::string BuildProtocolRequest(const std::string& request_body, |
22 const std::string& additional_attributes) { | 23 const std::string& additional_attributes) { |
23 const std::string prod_id(chrome::OmahaQueryParams::GetProdIdString( | 24 const std::string prod_id(chrome::OmahaQueryParams::GetProdIdString( |
24 chrome::OmahaQueryParams::CHROME)); | 25 chrome::OmahaQueryParams::CHROME)); |
25 const std::string chrome_version(chrome::VersionInfo().Version().c_str()); | 26 const chrome::VersionInfo chrome_version_info; |
| 27 const std::string chrome_version(chrome_version_info.Version()); |
26 | 28 |
27 std::string request( | 29 std::string request( |
28 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | 30 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" |
29 "<request protocol=\"3.0\" "); | 31 "<request protocol=\"3.0\" "); |
30 | 32 |
31 if (!additional_attributes.empty()) | 33 if (!additional_attributes.empty()) |
32 base::StringAppendF(&request, "%s ", additional_attributes.c_str()); | 34 base::StringAppendF(&request, "%s ", additional_attributes.c_str()); |
33 | 35 |
34 // Chrome version and platform information. | 36 // Chrome version and platform information. |
35 base::StringAppendF( | 37 base::StringAppendF( |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 // Network errors are small negative numbers. | 114 // Network errors are small negative numbers. |
113 const int error = fetcher.GetStatus().error(); | 115 const int error = fetcher.GetStatus().error(); |
114 return error ? error : -1; | 116 return error ? error : -1; |
115 } | 117 } |
116 | 118 |
117 default: | 119 default: |
118 return -1; | 120 return -1; |
119 } | 121 } |
120 } | 122 } |
121 | 123 |
| 124 bool HasDiffUpdate(const CrxUpdateItem* update_item) { |
| 125 return !update_item->crx_diffurls.empty(); |
| 126 } |
| 127 |
122 bool IsHttpServerError(int status_code) { | 128 bool IsHttpServerError(int status_code) { |
123 return 500 <= status_code && status_code < 600; | 129 return 500 <= status_code && status_code < 600; |
124 } | 130 } |
125 | 131 |
126 bool DeleteFileAndEmptyParentDirectory(const base::FilePath& filepath) { | 132 bool DeleteFileAndEmptyParentDirectory(const base::FilePath& filepath) { |
127 if (!base::DeleteFile(filepath, false)) | 133 if (!base::DeleteFile(filepath, false)) |
128 return false; | 134 return false; |
129 | 135 |
130 const base::FilePath dirname(filepath.DirName()); | 136 const base::FilePath dirname(filepath.DirName()); |
131 if (!base::IsDirectoryEmpty(dirname)) | 137 if (!base::IsDirectoryEmpty(dirname)) |
132 return true; | 138 return true; |
133 | 139 |
134 return base::DeleteFile(dirname, false); | 140 return base::DeleteFile(dirname, false); |
135 } | 141 } |
136 | 142 |
137 } // namespace component_updater | 143 } // namespace component_updater |
138 | 144 |
OLD | NEW |