OLD | NEW |
---|---|
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 "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 // that reference its members. When an accessor for a ChromeURLRequestContext is | 50 // that reference its members. When an accessor for a ChromeURLRequestContext is |
51 // invoked, then ProfileIOData will release its reference to the | 51 // invoked, then ProfileIOData will release its reference to the |
52 // ChromeURLRequestContext and the ChromeURLRequestContext will acquire a | 52 // ChromeURLRequestContext and the ChromeURLRequestContext will acquire a |
53 // reference to the ProfileIOData, so they exchange ownership. This is done | 53 // reference to the ProfileIOData, so they exchange ownership. This is done |
54 // because it's possible for a context's accessor never to be invoked, so this | 54 // because it's possible for a context's accessor never to be invoked, so this |
55 // ownership reversal prevents shutdown leaks. ProfileIOData will lazily | 55 // ownership reversal prevents shutdown leaks. ProfileIOData will lazily |
56 // initialize its members on the first invocation of a ChromeURLRequestContext | 56 // initialize its members on the first invocation of a ChromeURLRequestContext |
57 // accessor. | 57 // accessor. |
58 class ProfileIOData : public base::RefCountedThreadSafe<ProfileIOData> { | 58 class ProfileIOData : public base::RefCountedThreadSafe<ProfileIOData> { |
59 public: | 59 public: |
60 // These should only be called at most once each. Ownership is reversed they | 60 // These should only be called at most once each. Ownership is reversed when |
61 // get called, from ProfileIOData owning ChromeURLRequestContext to vice | 61 // they get called, from ProfileIOData owning ChromeURLRequestContext to vice |
62 // versa. | 62 // versa. |
63 scoped_refptr<ChromeURLRequestContext> GetMainRequestContext() const; | 63 scoped_refptr<ChromeURLRequestContext> GetMainRequestContext() const; |
64 scoped_refptr<ChromeURLRequestContext> GetMediaRequestContext() const; | 64 scoped_refptr<ChromeURLRequestContext> GetMediaRequestContext() const; |
65 scoped_refptr<ChromeURLRequestContext> GetExtensionsRequestContext() const; | 65 scoped_refptr<ChromeURLRequestContext> GetExtensionsRequestContext() const; |
66 scoped_refptr<ChromeURLRequestContext> GetIsolatedAppRequestContext( | |
67 scoped_refptr<ChromeURLRequestContext> main_context, | |
68 std::string app_id) const; | |
Matt Perry
2011/03/15 00:40:56
const std::string&
Charlie Reis
2011/03/15 06:23:42
Done.
| |
66 | 69 |
67 protected: | 70 protected: |
68 friend class base::RefCountedThreadSafe<ProfileIOData>; | 71 friend class base::RefCountedThreadSafe<ProfileIOData>; |
69 | 72 |
70 class RequestContext : public ChromeURLRequestContext { | 73 class RequestContext : public ChromeURLRequestContext { |
71 public: | 74 public: |
72 RequestContext(); | 75 RequestContext(); |
73 ~RequestContext(); | 76 ~RequestContext(); |
74 | 77 |
75 // Setter is used to transfer ownership of the ProfileIOData to the context. | 78 // Setter is used to transfer ownership of the ProfileIOData to the context. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 // Lazy initializes the ProfileIOData object the first time a request context | 135 // Lazy initializes the ProfileIOData object the first time a request context |
133 // is requested. The lazy logic is implemented here. The actual initialization | 136 // is requested. The lazy logic is implemented here. The actual initialization |
134 // is done in LazyInitializeInternal(), implemented by subtypes. Static helper | 137 // is done in LazyInitializeInternal(), implemented by subtypes. Static helper |
135 // functions have been provided to assist in common operations. | 138 // functions have been provided to assist in common operations. |
136 void LazyInitialize() const; | 139 void LazyInitialize() const; |
137 | 140 |
138 // -------------------------------------------- | 141 // -------------------------------------------- |
139 // Virtual interface for subtypes to implement: | 142 // Virtual interface for subtypes to implement: |
140 // -------------------------------------------- | 143 // -------------------------------------------- |
141 | 144 |
142 // Does that actual initialization of the ProfileIOData subtype. Subtypes | 145 // Does the actual initialization of the ProfileIOData subtype. Subtypes |
143 // should use the static helper functions above to implement this. | 146 // should use the static helper functions above to implement this. |
144 virtual void LazyInitializeInternal() const = 0; | 147 virtual void LazyInitializeInternal() const = 0; |
145 | 148 |
149 // Does an on-demand initialization of a RequestContext for the given | |
150 // isolated app. | |
151 virtual scoped_refptr<RequestContext> InitializeAppRequestContext( | |
152 scoped_refptr<ChromeURLRequestContext> main_context, | |
153 std::string app_id) const = 0; | |
Matt Perry
2011/03/15 00:40:56
here too, and below
Charlie Reis
2011/03/15 06:23:42
Done.
| |
154 | |
146 // These functions are used to transfer ownership of the lazily initialized | 155 // These functions are used to transfer ownership of the lazily initialized |
147 // context from ProfileIOData to the URLRequestContextGetter. | 156 // context from ProfileIOData to the URLRequestContextGetter. |
148 virtual scoped_refptr<ChromeURLRequestContext> | 157 virtual scoped_refptr<ChromeURLRequestContext> |
149 AcquireMainRequestContext() const = 0; | 158 AcquireMainRequestContext() const = 0; |
150 virtual scoped_refptr<ChromeURLRequestContext> | 159 virtual scoped_refptr<ChromeURLRequestContext> |
151 AcquireMediaRequestContext() const = 0; | 160 AcquireMediaRequestContext() const = 0; |
152 virtual scoped_refptr<ChromeURLRequestContext> | 161 virtual scoped_refptr<ChromeURLRequestContext> |
153 AcquireExtensionsRequestContext() const = 0; | 162 AcquireExtensionsRequestContext() const = 0; |
163 virtual scoped_refptr<ChromeURLRequestContext> | |
164 AcquireIsolatedAppRequestContext( | |
165 scoped_refptr<ChromeURLRequestContext> main_context, | |
166 std::string app_id) const = 0; | |
154 | 167 |
155 mutable bool initialized_; | 168 mutable bool initialized_; |
156 | 169 |
157 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); | 170 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); |
158 }; | 171 }; |
159 | 172 |
160 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ | 173 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ |
OLD | NEW |