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 const Extension* installed_app) const; |
66 | 68 |
67 protected: | 69 protected: |
68 friend class base::RefCountedThreadSafe<ProfileIOData>; | 70 friend class base::RefCountedThreadSafe<ProfileIOData>; |
69 | 71 |
70 class RequestContext : public ChromeURLRequestContext { | 72 class RequestContext : public ChromeURLRequestContext { |
71 public: | 73 public: |
72 RequestContext(); | 74 RequestContext(); |
73 ~RequestContext(); | 75 ~RequestContext(); |
74 | 76 |
75 // Setter is used to transfer ownership of the ProfileIOData to the context. | 77 // Setter is used to transfer ownership of the ProfileIOData to the context. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 // Lazy initializes the ProfileIOData object the first time a request context | 133 // Lazy initializes the ProfileIOData object the first time a request context |
132 // is requested. The lazy logic is implemented here. The actual initialization | 134 // is requested. The lazy logic is implemented here. The actual initialization |
133 // is done in LazyInitializeInternal(), implemented by subtypes. Static helper | 135 // is done in LazyInitializeInternal(), implemented by subtypes. Static helper |
134 // functions have been provided to assist in common operations. | 136 // functions have been provided to assist in common operations. |
135 void LazyInitialize() const; | 137 void LazyInitialize() const; |
136 | 138 |
137 // -------------------------------------------- | 139 // -------------------------------------------- |
138 // Virtual interface for subtypes to implement: | 140 // Virtual interface for subtypes to implement: |
139 // -------------------------------------------- | 141 // -------------------------------------------- |
140 | 142 |
141 // Does that actual initialization of the ProfileIOData subtype. Subtypes | 143 // Does the actual initialization of the ProfileIOData subtype. Subtypes |
142 // should use the static helper functions above to implement this. | 144 // should use the static helper functions above to implement this. |
143 virtual void LazyInitializeInternal() const = 0; | 145 virtual void LazyInitializeInternal() const = 0; |
144 | 146 |
| 147 // Does an on-demand initialization of a RequestContext for the given |
| 148 // isolated app. |
| 149 virtual scoped_refptr<RequestContext> |
| 150 InitializeAppRequestContext(const Extension *app) const = 0; |
| 151 |
145 // These functions are used to transfer ownership of the lazily initialized | 152 // These functions are used to transfer ownership of the lazily initialized |
146 // context from ProfileIOData to the URLRequestContextGetter. | 153 // context from ProfileIOData to the URLRequestContextGetter. |
147 virtual scoped_refptr<ChromeURLRequestContext> | 154 virtual scoped_refptr<ChromeURLRequestContext> |
148 AcquireMainRequestContext() const = 0; | 155 AcquireMainRequestContext() const = 0; |
149 virtual scoped_refptr<ChromeURLRequestContext> | 156 virtual scoped_refptr<ChromeURLRequestContext> |
150 AcquireMediaRequestContext() const = 0; | 157 AcquireMediaRequestContext() const = 0; |
151 virtual scoped_refptr<ChromeURLRequestContext> | 158 virtual scoped_refptr<ChromeURLRequestContext> |
152 AcquireExtensionsRequestContext() const = 0; | 159 AcquireExtensionsRequestContext() const = 0; |
| 160 virtual scoped_refptr<ChromeURLRequestContext> |
| 161 AcquireIsolatedAppRequestContext( |
| 162 const Extension* installed_app) const = 0; |
153 | 163 |
154 mutable bool initialized_; | 164 mutable bool initialized_; |
155 | 165 |
156 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); | 166 DISALLOW_COPY_AND_ASSIGN(ProfileIOData); |
157 }; | 167 }; |
158 | 168 |
159 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ | 169 #endif // CHROME_BROWSER_PROFILES_PROFILE_IO_DATA_H_ |
OLD | NEW |