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

Side by Side Diff: chrome/browser/profiles/profile_io_data.h

Issue 6825038: Create a content::ResourceContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test. Created 9 years, 8 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 #ifndef CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_
6 #define CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ 6 #define CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_
7 #pragma once 7 #pragma once
8 8
9 #include <set>
9 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/debug/stack_trace.h"
10 #include "base/file_path.h" 12 #include "base/file_path.h"
11 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/synchronization/lock.h"
13 #include "chrome/browser/net/chrome_url_request_context.h" 16 #include "chrome/browser/net/chrome_url_request_context.h"
14 #include "chrome/browser/prefs/pref_member.h" 17 #include "chrome/browser/prefs/pref_member.h"
15 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "content/browser/resource_context.h"
16 #include "net/base/cookie_monster.h" 20 #include "net/base/cookie_monster.h"
17 21
18 class CommandLine; 22 class CommandLine;
19 class ChromeAppCacheService; 23 class ChromeAppCacheService;
20 class ChromeBlobStorageContext; 24 class ChromeBlobStorageContext;
21 class ChromeURLRequestContext;
22 class ChromeURLRequestContextGetter;
23 class ExtensionInfoMap; 25 class ExtensionInfoMap;
24 namespace fileapi { 26 namespace fileapi {
25 class FileSystemContext; 27 class FileSystemContext;
26 } 28 } // namespace fileapi
27 class HostContentSettingsMap; 29 class HostContentSettingsMap;
28 class HostZoomMap; 30 class HostZoomMap;
29 class IOThread; 31 class IOThread;
30 namespace net { 32 namespace net {
31 class DnsCertProvenanceChecker; 33 class DnsCertProvenanceChecker;
32 class NetLog; 34 class NetLog;
33 class ProxyConfigService; 35 class ProxyConfigService;
34 class ProxyService; 36 class ProxyService;
35 class SSLConfigService; 37 class SSLConfigService;
36 class TransportSecurityState; 38 class TransportSecurityState;
(...skipping 23 matching lines...) Expand all
60 public: 62 public:
61 // These should only be called at most once each. Ownership is reversed when 63 // These should only be called at most once each. Ownership is reversed when
62 // they get called, from ProfileIOData owning ChromeURLRequestContext to vice 64 // they get called, from ProfileIOData owning ChromeURLRequestContext to vice
63 // versa. 65 // versa.
64 scoped_refptr<ChromeURLRequestContext> GetMainRequestContext() const; 66 scoped_refptr<ChromeURLRequestContext> GetMainRequestContext() const;
65 scoped_refptr<ChromeURLRequestContext> GetMediaRequestContext() const; 67 scoped_refptr<ChromeURLRequestContext> GetMediaRequestContext() const;
66 scoped_refptr<ChromeURLRequestContext> GetExtensionsRequestContext() const; 68 scoped_refptr<ChromeURLRequestContext> GetExtensionsRequestContext() const;
67 scoped_refptr<ChromeURLRequestContext> GetIsolatedAppRequestContext( 69 scoped_refptr<ChromeURLRequestContext> GetIsolatedAppRequestContext(
68 scoped_refptr<ChromeURLRequestContext> main_context, 70 scoped_refptr<ChromeURLRequestContext> main_context,
69 const std::string& app_id) const; 71 const std::string& app_id) const;
72 const content::ResourceContext& GetResourceContext() const;
70 73
71 protected: 74 protected:
72 friend class base::RefCountedThreadSafe<ProfileIOData>; 75 friend class base::RefCountedThreadSafe<ProfileIOData>;
73 76
74 class RequestContext : public ChromeURLRequestContext { 77 class RequestContext : public ChromeURLRequestContext {
75 public: 78 public:
76 RequestContext(); 79 RequestContext();
77 ~RequestContext(); 80 ~RequestContext();
78 81
79 // Setter is used to transfer ownership of the ProfileIOData to the context. 82 // Setter is used to transfer ownership of the ProfileIOData to the context.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 // because on linux it relies on initializing things through gconf, 116 // because on linux it relies on initializing things through gconf,
114 // and needs to be on the main thread. 117 // and needs to be on the main thread.
115 scoped_ptr<net::ProxyConfigService> proxy_config_service; 118 scoped_ptr<net::ProxyConfigService> proxy_config_service;
116 // The profile this struct was populated from. 119 // The profile this struct was populated from.
117 ProfileId profile_id; 120 ProfileId profile_id;
118 }; 121 };
119 122
120 explicit ProfileIOData(bool is_incognito); 123 explicit ProfileIOData(bool is_incognito);
121 virtual ~ProfileIOData(); 124 virtual ~ProfileIOData();
122 125
123 // Static helper functions to assist in common operations executed by 126 void InitializeProfileParams(Profile* profile);
124 // subtypes. 127 void ApplyProfileParamsToContext(ChromeURLRequestContext* context) const;
125
126 static void InitializeProfileParams(Profile* profile, ProfileParams* params);
127 static void ApplyProfileParamsToContext(const ProfileParams& profile_params,
128 ChromeURLRequestContext* context);
129 128
130 // Lazy initializes the ProfileIOData object the first time a request context 129 // Lazy initializes the ProfileIOData object the first time a request context
131 // is requested. The lazy logic is implemented here. The actual initialization 130 // is requested. The lazy logic is implemented here. The actual initialization
132 // is done in LazyInitializeInternal(), implemented by subtypes. Static helper 131 // is done in LazyInitializeInternal(), implemented by subtypes. Static helper
133 // functions have been provided to assist in common operations. 132 // functions have been provided to assist in common operations.
134 void LazyInitialize() const; 133 void LazyInitialize() const;
135 134
136 // Called when the profile is destroyed. 135 // Called when the profile is destroyed.
137 void ShutdownOnUIThread(); 136 void ShutdownOnUIThread();
138 137
139 BooleanPrefMember* enable_referrers() const { 138 BooleanPrefMember* enable_referrers() const {
140 return &enable_referrers_; 139 return &enable_referrers_;
141 } 140 }
142 141
143 private: 142 private:
143 class ResourceContext : public content::ResourceContext {
144 public:
145 explicit ResourceContext(const ProfileIOData* io_data);
146 virtual ~ResourceContext();
147
148 private:
149 virtual void EnsureInitialized() const;
150
151 const ProfileIOData* const io_data_;
152 };
153
144 // -------------------------------------------- 154 // --------------------------------------------
145 // Virtual interface for subtypes to implement: 155 // Virtual interface for subtypes to implement:
146 // -------------------------------------------- 156 // --------------------------------------------
147 157
148 // Does the actual initialization of the ProfileIOData subtype. Subtypes 158 // Does the actual initialization of the ProfileIOData subtype. Subtypes
149 // should use the static helper functions above to implement this. 159 // should use the static helper functions above to implement this.
150 virtual void LazyInitializeInternal() const = 0; 160 virtual void LazyInitializeInternal(ProfileParams* profile_params) const = 0;
151 161
152 // Does an on-demand initialization of a RequestContext for the given 162 // Does an on-demand initialization of a RequestContext for the given
153 // isolated app. 163 // isolated app.
154 virtual scoped_refptr<RequestContext> InitializeAppRequestContext( 164 virtual scoped_refptr<RequestContext> InitializeAppRequestContext(
155 scoped_refptr<ChromeURLRequestContext> main_context, 165 scoped_refptr<ChromeURLRequestContext> main_context,
156 const std::string& app_id) const = 0; 166 const std::string& app_id) const = 0;
157 167
158 // These functions are used to transfer ownership of the lazily initialized 168 // These functions are used to transfer ownership of the lazily initialized
159 // context from ProfileIOData to the URLRequestContextGetter. 169 // context from ProfileIOData to the URLRequestContextGetter.
160 virtual scoped_refptr<ChromeURLRequestContext> 170 virtual scoped_refptr<ChromeURLRequestContext>
161 AcquireMainRequestContext() const = 0; 171 AcquireMainRequestContext() const = 0;
162 virtual scoped_refptr<ChromeURLRequestContext> 172 virtual scoped_refptr<ChromeURLRequestContext>
163 AcquireMediaRequestContext() const = 0; 173 AcquireMediaRequestContext() const = 0;
164 virtual scoped_refptr<ChromeURLRequestContext> 174 virtual scoped_refptr<ChromeURLRequestContext>
165 AcquireExtensionsRequestContext() const = 0; 175 AcquireExtensionsRequestContext() const = 0;
166 virtual scoped_refptr<ChromeURLRequestContext> 176 virtual scoped_refptr<ChromeURLRequestContext>
167 AcquireIsolatedAppRequestContext( 177 AcquireIsolatedAppRequestContext(
168 scoped_refptr<ChromeURLRequestContext> main_context, 178 scoped_refptr<ChromeURLRequestContext> main_context,
169 const std::string& app_id) const = 0; 179 const std::string& app_id) const = 0;
170 180
181 mutable bool initialized_;
182 mutable scoped_ptr<ProfileParams> profile_params_;
171 mutable BooleanPrefMember enable_referrers_; 183 mutable BooleanPrefMember enable_referrers_;
172 mutable bool initialized_; 184 mutable scoped_refptr<webkit_database::DatabaseTracker> database_tracker_;
185 mutable ResourceContext resource_context_;
173 186
174 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); 187 DISALLOW_COPY_AND_ASSIGN(ProfileIOData);
175 }; 188 };
176 189
177 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ 190 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl_io_data.cc ('k') | chrome/browser/profiles/profile_io_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698