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

Side by Side Diff: chrome/browser/component_updater/update_checker.cc

Issue 216923006: Add a component updater for the CLD2 data file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase onto latest master Created 6 years, 7 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
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698