OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/update_checker.h" | 5 #include "chrome/browser/component_updater/update_checker.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/logging.h" |
8 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
9 #include "chrome/browser/component_updater/component_updater_utils.h" | 10 #include "chrome/browser/component_updater/component_updater_utils.h" |
10 #include "chrome/browser/component_updater/crx_update_item.h" | 11 #include "chrome/browser/component_updater/crx_update_item.h" |
11 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
12 #include "net/url_request/url_fetcher.h" | 13 #include "net/url_request/url_fetcher.h" |
13 #include "net/url_request/url_fetcher_delegate.h" | 14 #include "net/url_request/url_fetcher_delegate.h" |
14 #include "url/gurl.h" | 15 #include "url/gurl.h" |
15 | 16 |
16 using content::BrowserThread; | 17 using content::BrowserThread; |
17 | 18 |
(...skipping 29 matching lines...) Expand all Loading... |
47 base::StringAppendF(&app, "<updatecheck />"); | 48 base::StringAppendF(&app, "<updatecheck />"); |
48 if (!item->component.fingerprint.empty()) { | 49 if (!item->component.fingerprint.empty()) { |
49 base::StringAppendF(&app, | 50 base::StringAppendF(&app, |
50 "<packages>" | 51 "<packages>" |
51 "<package fp=\"%s\"/>" | 52 "<package fp=\"%s\"/>" |
52 "</packages>", | 53 "</packages>", |
53 item->component.fingerprint.c_str()); | 54 item->component.fingerprint.c_str()); |
54 } | 55 } |
55 base::StringAppendF(&app, "</app>"); | 56 base::StringAppendF(&app, "</app>"); |
56 app_elements.append(app); | 57 app_elements.append(app); |
| 58 VLOG(1) << "Appending to update request: " << app; |
57 } | 59 } |
58 | 60 |
59 return BuildProtocolRequest(app_elements, additional_attributes); | 61 return BuildProtocolRequest(app_elements, additional_attributes); |
60 } | 62 } |
61 | 63 |
62 class UpdateCheckerImpl | 64 class UpdateCheckerImpl |
63 : public UpdateChecker, | 65 : public UpdateChecker, |
64 public net::URLFetcherDelegate { | 66 public net::URLFetcherDelegate { |
65 public: | 67 public: |
66 UpdateCheckerImpl(const GURL& url, | 68 UpdateCheckerImpl(const GURL& url, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 int error = 0; | 135 int error = 0; |
134 std::string error_message; | 136 std::string error_message; |
135 UpdateResponse update_response; | 137 UpdateResponse update_response; |
136 | 138 |
137 if (FetchSuccess(*source)) { | 139 if (FetchSuccess(*source)) { |
138 std::string xml; | 140 std::string xml; |
139 source->GetResponseAsString(&xml); | 141 source->GetResponseAsString(&xml); |
140 if (!update_response.Parse(xml)) { | 142 if (!update_response.Parse(xml)) { |
141 error = -1; | 143 error = -1; |
142 error_message = update_response.errors(); | 144 error_message = update_response.errors(); |
| 145 VLOG(1) << "Update request failed: " << error_message; |
143 } | 146 } |
144 } else { | 147 } else { |
145 error = GetFetchError(*source); | 148 error = GetFetchError(*source); |
146 error_message.assign("network error"); | 149 error_message.assign("network error"); |
| 150 VLOG(1) << "Update request failed: network error"; |
147 } | 151 } |
148 | 152 |
149 url_fetcher_.reset(); | 153 url_fetcher_.reset(); |
150 update_check_callback_.Run(error, error_message, update_response.results()); | 154 update_check_callback_.Run(error, error_message, update_response.results()); |
151 } | 155 } |
152 | 156 |
153 } // namespace component_updater | 157 } // namespace component_updater |
154 | 158 |
OLD | NEW |