| OLD | NEW | 
|    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 #include "chrome/browser/net/http_server_properties_manager.h" |    4 #include "chrome/browser/net/http_server_properties_manager.h" | 
|    5  |    5  | 
|    6 #include "base/bind.h" |    6 #include "base/bind.h" | 
|    7 #include "base/stl_util.h" |    7 #include "base/stl_util.h" | 
|    8 #include "base/string_number_conversions.h" |    8 #include "base/string_number_conversions.h" | 
|    9 #include "base/stringprintf.h" |    9 #include "base/stringprintf.h" | 
|   10 #include "base/values.h" |   10 #include "base/values.h" | 
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   50     : pref_service_(pref_service), |   50     : pref_service_(pref_service), | 
|   51       setting_prefs_(false) { |   51       setting_prefs_(false) { | 
|   52   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |   52   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 
|   53   DCHECK(pref_service); |   53   DCHECK(pref_service); | 
|   54   ui_weak_ptr_factory_.reset( |   54   ui_weak_ptr_factory_.reset( | 
|   55       new base::WeakPtrFactory<HttpServerPropertiesManager>(this)); |   55       new base::WeakPtrFactory<HttpServerPropertiesManager>(this)); | 
|   56   ui_weak_ptr_ = ui_weak_ptr_factory_->GetWeakPtr(); |   56   ui_weak_ptr_ = ui_weak_ptr_factory_->GetWeakPtr(); | 
|   57   ui_cache_update_timer_.reset( |   57   ui_cache_update_timer_.reset( | 
|   58       new base::OneShotTimer<HttpServerPropertiesManager>); |   58       new base::OneShotTimer<HttpServerPropertiesManager>); | 
|   59   pref_change_registrar_.Init(pref_service_); |   59   pref_change_registrar_.Init(pref_service_); | 
|   60   pref_change_registrar_.Add(prefs::kHttpServerProperties, this); |   60   pref_change_registrar_.Add( | 
 |   61       prefs::kHttpServerProperties, | 
 |   62       base::Bind(&HttpServerPropertiesManager::OnHttpServerPropertiesChanged, | 
 |   63                  base::Unretained(this))); | 
|   61 } |   64 } | 
|   62  |   65  | 
|   63 HttpServerPropertiesManager::~HttpServerPropertiesManager() { |   66 HttpServerPropertiesManager::~HttpServerPropertiesManager() { | 
|   64 } |   67 } | 
|   65  |   68  | 
|   66 void HttpServerPropertiesManager::InitializeOnIOThread() { |   69 void HttpServerPropertiesManager::InitializeOnIOThread() { | 
|   67   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |   70   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 
|   68   http_server_properties_impl_.reset(new net::HttpServerPropertiesImpl()); |   71   http_server_properties_impl_.reset(new net::HttpServerPropertiesImpl()); | 
|   69  |   72  | 
|   70   io_prefs_update_timer_.reset( |   73   io_prefs_update_timer_.reset( | 
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  649   setting_prefs_ = false; |  652   setting_prefs_ = false; | 
|  650  |  653  | 
|  651   // Note that |completion| will be fired after we have written everything to |  654   // Note that |completion| will be fired after we have written everything to | 
|  652   // the Preferences, but likely before these changes are serialized to disk. |  655   // the Preferences, but likely before these changes are serialized to disk. | 
|  653   // This is not a problem though, as JSONPrefStore guarantees that this will |  656   // This is not a problem though, as JSONPrefStore guarantees that this will | 
|  654   // happen, pretty soon, and even in the case we shut down immediately. |  657   // happen, pretty soon, and even in the case we shut down immediately. | 
|  655   if (!completion.is_null()) |  658   if (!completion.is_null()) | 
|  656     completion.Run(); |  659     completion.Run(); | 
|  657 } |  660 } | 
|  658  |  661  | 
|  659 void HttpServerPropertiesManager::OnPreferenceChanged( |  662 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { | 
|  660     PrefServiceBase* prefs, |  | 
|  661     const std::string& pref_name) { |  | 
|  662   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |  663   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 
|  663   DCHECK(prefs == pref_service_); |  664   if (!setting_prefs_) | 
|  664   if (pref_name == prefs::kHttpServerProperties) { |  665     ScheduleUpdateCacheOnUI(); | 
|  665     if (!setting_prefs_) |  | 
|  666       ScheduleUpdateCacheOnUI(); |  | 
|  667   } else { |  | 
|  668     NOTREACHED(); |  | 
|  669   } |  | 
|  670 } |  666 } | 
|  671  |  667  | 
|  672 }  // namespace chrome_browser_net |  668 }  // namespace chrome_browser_net | 
| OLD | NEW |