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

Side by Side Diff: chrome/browser/chromeos/customization_document.cc

Issue 15907017: Convert CustomizationDocument class to use NetworkStateHandler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chromeos/customization_document.h" 5 #include "chrome/browser/chromeos/customization_document.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/json/json_reader.h" 11 #include "base/json/json_reader.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/prefs/pref_registry_simple.h" 13 #include "base/prefs/pref_registry_simple.h"
14 #include "base/prefs/pref_service.h" 14 #include "base/prefs/pref_service.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "base/time.h" 16 #include "base/time.h"
17 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/chromeos/cros/cros_library.h"
20 #include "chrome/browser/chromeos/cros/network_library.h"
21 #include "chrome/browser/chromeos/login/wizard_controller.h" 19 #include "chrome/browser/chromeos/login/wizard_controller.h"
22 #include "chrome/browser/chromeos/system/statistics_provider.h" 20 #include "chrome/browser/chromeos/system/statistics_provider.h"
23 #include "chrome/browser/profiles/profile_manager.h" 21 #include "chrome/browser/profiles/profile_manager.h"
22 #include "chromeos/network/network_state.h"
23 #include "chromeos/network/network_state_handler.h"
24 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
25 #include "net/url_request/url_fetcher.h" 25 #include "net/url_request/url_fetcher.h"
26 26
27 using content::BrowserThread; 27 using content::BrowserThread;
28 28
29 // Manifest attributes names. 29 // Manifest attributes names.
30 30
31 namespace { 31 namespace {
32 32
33 const char kVersionAttr[] = "version"; 33 const char kVersionAttr[] = "version";
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 url_fetcher_->Start(); 303 url_fetcher_->Start();
304 } 304 }
305 305
306 void ServicesCustomizationDocument::OnURLFetchComplete( 306 void ServicesCustomizationDocument::OnURLFetchComplete(
307 const net::URLFetcher* source) { 307 const net::URLFetcher* source) {
308 if (source->GetResponseCode() == 200) { 308 if (source->GetResponseCode() == 200) {
309 std::string data; 309 std::string data;
310 source->GetResponseAsString(&data); 310 source->GetResponseAsString(&data);
311 LoadManifestFromString(data); 311 LoadManifestFromString(data);
312 } else { 312 } else {
313 NetworkLibrary* network = CrosLibrary::Get()->GetNetworkLibrary(); 313 const NetworkState* default_network =
314 if (!network->Connected() && num_retries_ < kMaxFetchRetries) { 314 NetworkHandler::Get()->network_state_handler()->DefaultNetwork();
315 if (default_network && default_network->IsConnectedState() &&
316 num_retries_ < kMaxFetchRetries) {
315 num_retries_++; 317 num_retries_++;
316 retry_timer_.Start(FROM_HERE, 318 retry_timer_.Start(FROM_HERE,
317 base::TimeDelta::FromSeconds(kRetriesDelayInSec), 319 base::TimeDelta::FromSeconds(kRetriesDelayInSec),
318 this, &ServicesCustomizationDocument::StartFileFetch); 320 this, &ServicesCustomizationDocument::StartFileFetch);
319 return; 321 return;
320 } 322 }
321 LOG(ERROR) << "URL fetch for services customization failed:" 323 LOG(ERROR) << "URL fetch for services customization failed:"
322 << " response code = " << source->GetResponseCode() 324 << " response code = " << source->GetResponseCode()
323 << " URL = " << source->GetURL().spec(); 325 << " URL = " << source->GetURL().spec();
324 } 326 }
(...skipping 11 matching lines...) Expand all
336 locale, kAppContentAttr, kInitialStartPageAttr); 338 locale, kAppContentAttr, kInitialStartPageAttr);
337 } 339 }
338 340
339 std::string ServicesCustomizationDocument::GetSupportPage( 341 std::string ServicesCustomizationDocument::GetSupportPage(
340 const std::string& locale) const { 342 const std::string& locale) const {
341 return GetLocaleSpecificString( 343 return GetLocaleSpecificString(
342 locale, kAppContentAttr, kSupportPageAttr); 344 locale, kAppContentAttr, kSupportPageAttr);
343 } 345 }
344 346
345 } // namespace chromeos 347 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698