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

Side by Side Diff: chrome/browser/net/spdy_config_service_manager.h

Issue 7827033: Introduce net::HttpServerPropertiesManager to manage server-specific properties. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_NET_SPDY_CONFIG_SERVICE_MANAGER_H_
6 #define CHROME_BROWSER_NET_SPDY_CONFIG_SERVICE_MANAGER_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h"
13 #include "chrome/browser/prefs/pref_change_registrar.h"
14 #include "chrome/browser/prefs/pref_member.h"
15 #include "chrome/browser/prefs/pref_service.h"
16 #include "chrome/common/chrome_notification_types.h"
17 #include "chrome/common/pref_names.h"
18 #include "content/common/notification_details.h"
19 #include "content/common/notification_source.h"
20 #include "net/spdy/spdy_config_service.h"
21
22 class PrefService;
23 class SpdyConfigServiceManager;
24
25 ////////////////////////////////////////////////////////////////////////////////
26 // SpdyConfigServicePref
27
28 // An SpdyConfigService which stores a cached version of the current SpdyConfig
29 // prefs. Wheneve SpdyConfig changes, it persists the data into user
30 // preferences.
31 class SpdyConfigServicePref : public net::SpdyConfigService {
32 public:
33 SpdyConfigServicePref();
34 virtual ~SpdyConfigServicePref();
35
36 // Store SPDY config settings in |config|. Must only be called from IO thread.
37 virtual void GetSpdyConfig(net::SpdyConfig* config);
38
39 // Add |spdy_server| as the server which supports SPDY protocol into the
40 // persisitent store. Should only be called from IO thread.
41 virtual void AddSpdyServer(const std::string& spdy_server);
42
43 private:
44 // Allow the pref watcher to update our internal state.
45 friend class SpdyConfigServiceManager;
46
47 // Cached value of prefs, should only be accessed from IO thread.
48 net::SpdyConfig cached_config_;
49
50 scoped_refptr<SpdyConfigServiceManager> spdy_config_service_manager_;
51
52 DISALLOW_COPY_AND_ASSIGN(SpdyConfigServicePref);
53 };
54
55 ////////////////////////////////////////////////////////////////////////////////
56 // SpdyConfigServiceManager
57
58 // The manager for creating and updating an SpdyConfigService objects.
59 class SpdyConfigServiceManager
60 : public NotificationObserver,
61 public base::RefCountedThreadSafe<SpdyConfigServiceManager> {
62 public:
63 // Create an instance of the SpdyConfigServiceManager. The lifetime of the
64 // PrefService objects must be longer than that of the manager.
65 explicit SpdyConfigServiceManager();
66 virtual ~SpdyConfigServiceManager();
67
68 // Get an SpdyConfigService instance. It may be a new instance or the manager
69 // may return the same instance multiple times.
70 // The caller should hold a reference as long as it needs the instance (eg,
71 // using scoped_refptr.)
72 virtual net::SpdyConfigService* Get();
73
74 // Register |prefs| Spdy preferences.
75 static void RegisterPrefs(PrefService* prefs);
76
77 // Get SPDY preferences from |prefs| object.
78 void Initialize(PrefService* prefs);
79
80 // Prepare for shutdown.
81 void Cleanup();
82
83 // Store Spdy config settings in user preferences with the data from
84 // |spdy_config_service_|'s |caced_config_|. Must only be called from UI
85 // thread.
86 void SetSpdyConfigInPrefs();
87
88 protected:
89 friend class base::RefCountedThreadSafe<SpdyConfigServiceManager>;
90
91 private:
92 // Callback for preference changes. We ignore tha changes in preferences.
93 virtual void Observe(int type,
94 const NotificationSource& source,
95 const NotificationDetails& details);
96
97 PrefChangeRegistrar pref_change_registrar_;
98
99 // |spdy_servers_| is flattened representation of servers (host/port pair)
100 // that support SPDY protocol. The prefs should only be accessed from UI
101 // thread.
102 StringPrefMember spdy_servers_;
103
104 scoped_refptr<SpdyConfigServicePref> spdy_config_service_;
105
106 DISALLOW_COPY_AND_ASSIGN(SpdyConfigServiceManager);
107 };
108
109 #endif // CHROME_BROWSER_NET_SPDY_CONFIG_SERVICE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698