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

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

Issue 5671003: [Chrome OS] Plumb new error codes from SignedSettings to consumers of the API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments per dilmah Created 10 years 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/proxy_config_service_impl.h" 5 #include "chrome/browser/chromeos/proxy_config_service_impl.h"
6 6
7 #include <ostream> 7 #include <ostream>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 // Should be called from IO thread. 482 // Should be called from IO thread.
483 CheckCurrentlyOnIOThread(); 483 CheckCurrentlyOnIOThread();
484 if (has_config_) { 484 if (has_config_) {
485 // Simply return the last cached proxy configuration. 485 // Simply return the last cached proxy configuration.
486 cached_config_.ToNetProxyConfig(net_config); 486 cached_config_.ToNetProxyConfig(net_config);
487 return true; 487 return true;
488 } 488 }
489 return false; 489 return false;
490 } 490 }
491 491
492 void ProxyConfigServiceImpl::OnSettingsOpSucceeded(bool value) { 492 void ProxyConfigServiceImpl::OnSettingsOpCompleted(
493 VLOG(1) << "Stored proxy setting to device"; 493 SignedSettings::ReturnCode code,
494 bool value) {
494 store_property_op_ = NULL; 495 store_property_op_ = NULL;
495 if (persist_to_device_pending_) 496 if (SignedSettings::SUCCESS == code) {
496 PersistConfigToDevice(); 497 VLOG(1) << "Stored proxy setting to device";
498 if (persist_to_device_pending_)
499 PersistConfigToDevice();
500 } else {
501 LOG(WARNING) << "Error storing proxy setting to device";
502 if (persist_to_device_pending_)
503 PersistConfigToDevice();
xiyuan 2010/12/09 17:55:39 nit: let's move this out of the "if" since we do t
504 }
497 } 505 }
498 506
499 void ProxyConfigServiceImpl::OnSettingsOpSucceeded(std::string value) { 507 void ProxyConfigServiceImpl::OnSettingsOpCompleted(
500 VLOG(1) << "Retrieved proxy setting from device, value=[" << value << "]"; 508 SignedSettings::ReturnCode code,
501 if (reference_config_.Deserialize(value)) { 509 std::string value) {
502 OnUISetProxyConfig(false); 510 if (SignedSettings::SUCCESS == code) {
511 VLOG(1) << "Retrieved proxy setting from device, value=[" << value << "]";
512 if (reference_config_.Deserialize(value)) {
513 OnUISetProxyConfig(false);
514 } else {
515 LOG(WARNING) << "Error deserializing device's proxy setting";
516 InitConfigToDefault(true);
517 }
503 } else { 518 } else {
504 LOG(WARNING) << "Error deserializing device's proxy setting"; 519 LOG(WARNING) << "Error retrieving proxy setting from device";
505 InitConfigToDefault(true); 520 InitConfigToDefault(true);
506 } 521 }
507 retrieve_property_op_ = NULL; 522 retrieve_property_op_ = NULL;
508 } 523 }
509 524
510 void ProxyConfigServiceImpl::OnSettingsOpFailed(
511 SignedSettings::FailureCode code) {
512 if (retrieve_property_op_) {
513 LOG(WARNING) << "Error retrieving proxy setting from device";
514 InitConfigToDefault(true);
515 retrieve_property_op_ = NULL;
516 } else {
517 LOG(WARNING) << "Error storing proxy setting to device";
518 store_property_op_ = NULL;
519 if (persist_to_device_pending_)
520 PersistConfigToDevice();
521 }
522 }
523
524 //------------------ ProxyConfigServiceImpl: private methods ------------------- 525 //------------------ ProxyConfigServiceImpl: private methods -------------------
525 526
526 void ProxyConfigServiceImpl::InitConfigToDefault(bool post_to_io_thread) { 527 void ProxyConfigServiceImpl::InitConfigToDefault(bool post_to_io_thread) {
527 VLOG(1) << "Using default proxy config: auto-detect"; 528 VLOG(1) << "Using default proxy config: auto-detect";
528 reference_config_.mode = ProxyConfig::MODE_AUTO_DETECT; 529 reference_config_.mode = ProxyConfig::MODE_AUTO_DETECT;
529 reference_config_.automatic_proxy.source = ProxyConfig::SOURCE_OWNER; 530 reference_config_.automatic_proxy.source = ProxyConfig::SOURCE_OWNER;
530 if (post_to_io_thread && can_post_task_) { 531 if (post_to_io_thread && can_post_task_) {
531 OnUISetProxyConfig(false); 532 OnUISetProxyConfig(false);
532 } else { 533 } else {
533 // Update the IO-accessible copy in |cached_config_| as well. 534 // Update the IO-accessible copy in |cached_config_| as well.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 has_config_ = true; 586 has_config_ = true;
586 cached_config_ = new_config; 587 cached_config_ = new_config;
587 // Notify observers of new proxy config. 588 // Notify observers of new proxy config.
588 net::ProxyConfig net_config; 589 net::ProxyConfig net_config;
589 cached_config_.ToNetProxyConfig(&net_config); 590 cached_config_.ToNetProxyConfig(&net_config);
590 FOR_EACH_OBSERVER(net::ProxyConfigService::Observer, observers_, 591 FOR_EACH_OBSERVER(net::ProxyConfigService::Observer, observers_,
591 OnProxyConfigChanged(net_config)); 592 OnProxyConfigChanged(net_config));
592 } 593 }
593 594
594 } // namespace chromeos 595 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/proxy_config_service_impl.h ('k') | chrome/browser/chromeos/user_cros_settings_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698