| Index: chrome/browser/net/spdy_config_service_manager.cc
|
| ===================================================================
|
| --- chrome/browser/net/spdy_config_service_manager.cc (revision 0)
|
| +++ chrome/browser/net/spdy_config_service_manager.cc (revision 0)
|
| @@ -0,0 +1,83 @@
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +#include "chrome/browser/net/spdy_config_service_manager.h"
|
| +
|
| +#include <string>
|
| +
|
| +#include "content/browser/browser_thread.h"
|
| +
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +// SpdyConfigServicePref
|
| +
|
| +SpdyConfigServicePref::SpdyConfigServicePref() {
|
| +}
|
| +
|
| +SpdyConfigServicePref::~SpdyConfigServicePref() {
|
| +}
|
| +
|
| +void SpdyConfigServicePref::GetSpdyConfig(net::SpdyConfig* config) {
|
| + *config = cached_config_;
|
| +}
|
| +
|
| +void SpdyConfigServicePref::AddSpdyServer(const std::string& spdy_server) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| + if (cached_config_.spdy_servers.find(spdy_server) != std::string::npos)
|
| + return;
|
| + // Copy the data.
|
| + cached_config_.spdy_servers.append(spdy_server);
|
| + BrowserThread::PostTask(
|
| + BrowserThread::UI,
|
| + FROM_HERE,
|
| + NewRunnableMethod(spdy_config_service_manager_.get(),
|
| + &SpdyConfigServiceManager::SetSpdyConfigInPrefs));
|
| +}
|
| +
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +// SpdyConfigServiceManager
|
| +
|
| +SpdyConfigServiceManager::SpdyConfigServiceManager()
|
| + : spdy_config_service_(new SpdyConfigServicePref()) {
|
| + spdy_config_service_->spdy_config_service_manager_ = this;
|
| + spdy_config_service_->cached_config_.spdy_servers = std::string();
|
| +}
|
| +
|
| +SpdyConfigServiceManager::~SpdyConfigServiceManager() {
|
| +}
|
| +
|
| +net::SpdyConfigService* SpdyConfigServiceManager::Get() {
|
| + return spdy_config_service_;
|
| +}
|
| +
|
| +// static
|
| +void SpdyConfigServiceManager::RegisterPrefs(PrefService* prefs) {
|
| + prefs->RegisterStringPref(
|
| + prefs::kSpdyServers, std::string(), PrefService::UNSYNCABLE_PREF);
|
| +}
|
| +
|
| +void SpdyConfigServiceManager::Initialize(PrefService* prefs) {
|
| + DCHECK(prefs);
|
| +
|
| + spdy_servers_.Init(prefs::kSpdyServers, prefs, this);
|
| + pref_change_registrar_.Init(prefs);
|
| +
|
| + // Initialize from UI thread. This is okay as there shouldn't be anything on
|
| + // the IO thread trying to access it yet.
|
| + spdy_config_service_->cached_config_.spdy_servers =
|
| + spdy_servers_.GetValue();
|
| +}
|
| +
|
| +void SpdyConfigServiceManager::Cleanup() {
|
| + spdy_config_service_->spdy_config_service_manager_ = NULL;
|
| + spdy_servers_.Destroy();
|
| +}
|
| +
|
| +void SpdyConfigServiceManager::SetSpdyConfigInPrefs() {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + spdy_servers_.SetValue(spdy_config_service_->cached_config_.spdy_servers);
|
| +}
|
| +
|
| +void SpdyConfigServiceManager::Observe(int type,
|
| + const NotificationSource& source,
|
| + const NotificationDetails& details) {
|
| +}
|
|
|