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