| Index: chrome/browser/net/spdy_config_service_manager.h
|
| ===================================================================
|
| --- chrome/browser/net/spdy_config_service_manager.h (revision 0)
|
| +++ chrome/browser/net/spdy_config_service_manager.h (revision 0)
|
| @@ -0,0 +1,109 @@
|
| +// 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.
|
| +
|
| +#ifndef CHROME_BROWSER_NET_SPDY_CONFIG_SERVICE_MANAGER_H_
|
| +#define CHROME_BROWSER_NET_SPDY_CONFIG_SERVICE_MANAGER_H_
|
| +#pragma once
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/basictypes.h"
|
| +#include "base/memory/ref_counted.h"
|
| +#include "chrome/browser/prefs/pref_change_registrar.h"
|
| +#include "chrome/browser/prefs/pref_member.h"
|
| +#include "chrome/browser/prefs/pref_service.h"
|
| +#include "chrome/common/chrome_notification_types.h"
|
| +#include "chrome/common/pref_names.h"
|
| +#include "content/common/notification_details.h"
|
| +#include "content/common/notification_source.h"
|
| +#include "net/spdy/spdy_config_service.h"
|
| +
|
| +class PrefService;
|
| +class SpdyConfigServiceManager;
|
| +
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +// SpdyConfigServicePref
|
| +
|
| +// An SpdyConfigService which stores a cached version of the current SpdyConfig
|
| +// prefs. Wheneve SpdyConfig changes, it persists the data into user
|
| +// preferences.
|
| +class SpdyConfigServicePref : public net::SpdyConfigService {
|
| + public:
|
| + SpdyConfigServicePref();
|
| + virtual ~SpdyConfigServicePref();
|
| +
|
| + // Store SPDY config settings in |config|. Must only be called from IO thread.
|
| + virtual void GetSpdyConfig(net::SpdyConfig* config);
|
| +
|
| + // Add |spdy_server| as the server which supports SPDY protocol into the
|
| + // persisitent store. Should only be called from IO thread.
|
| + virtual void AddSpdyServer(const std::string& spdy_server);
|
| +
|
| + private:
|
| + // Allow the pref watcher to update our internal state.
|
| + friend class SpdyConfigServiceManager;
|
| +
|
| + // Cached value of prefs, should only be accessed from IO thread.
|
| + net::SpdyConfig cached_config_;
|
| +
|
| + scoped_refptr<SpdyConfigServiceManager> spdy_config_service_manager_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(SpdyConfigServicePref);
|
| +};
|
| +
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +// SpdyConfigServiceManager
|
| +
|
| +// The manager for creating and updating an SpdyConfigService objects.
|
| +class SpdyConfigServiceManager
|
| + : public NotificationObserver,
|
| + public base::RefCountedThreadSafe<SpdyConfigServiceManager> {
|
| + public:
|
| + // Create an instance of the SpdyConfigServiceManager. The lifetime of the
|
| + // PrefService objects must be longer than that of the manager.
|
| + explicit SpdyConfigServiceManager();
|
| + virtual ~SpdyConfigServiceManager();
|
| +
|
| + // Get an SpdyConfigService instance. It may be a new instance or the manager
|
| + // may return the same instance multiple times.
|
| + // The caller should hold a reference as long as it needs the instance (eg,
|
| + // using scoped_refptr.)
|
| + virtual net::SpdyConfigService* Get();
|
| +
|
| + // Register |prefs| Spdy preferences.
|
| + static void RegisterPrefs(PrefService* prefs);
|
| +
|
| + // Get SPDY preferences from |prefs| object.
|
| + void Initialize(PrefService* prefs);
|
| +
|
| + // Prepare for shutdown.
|
| + void Cleanup();
|
| +
|
| + // Store Spdy config settings in user preferences with the data from
|
| + // |spdy_config_service_|'s |caced_config_|. Must only be called from UI
|
| + // thread.
|
| + void SetSpdyConfigInPrefs();
|
| +
|
| + protected:
|
| + friend class base::RefCountedThreadSafe<SpdyConfigServiceManager>;
|
| +
|
| + private:
|
| + // Callback for preference changes. We ignore tha changes in preferences.
|
| + virtual void Observe(int type,
|
| + const NotificationSource& source,
|
| + const NotificationDetails& details);
|
| +
|
| + PrefChangeRegistrar pref_change_registrar_;
|
| +
|
| + // |spdy_servers_| is flattened representation of servers (host/port pair)
|
| + // that support SPDY protocol. The prefs should only be accessed from UI
|
| + // thread.
|
| + StringPrefMember spdy_servers_;
|
| +
|
| + scoped_refptr<SpdyConfigServicePref> spdy_config_service_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(SpdyConfigServiceManager);
|
| +};
|
| +
|
| +#endif // CHROME_BROWSER_NET_SPDY_CONFIG_SERVICE_MANAGER_H_
|
|
|