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

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

Issue 6201005: Initial support for partitioning cookies for isolated apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add ChromeURLRequestContext::Copy. Created 9 years, 9 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_IMPL_IO_DATA_H_ 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_IMPL_IO_DATA_H_
6 #define CHROME_BROWSER_PROFILES_PROFILE_IMPL_IO_DATA_H_ 6 #define CHROME_BROWSER_PROFILES_PROFILE_IMPL_IO_DATA_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/hash_tables.h"
10 #include "base/ref_counted.h" 11 #include "base/ref_counted.h"
11 #include "chrome/browser/profiles/profile_io_data.h" 12 #include "chrome/browser/profiles/profile_io_data.h"
12 13
13 namespace net { 14 namespace net {
14 class NetworkDelegate; 15 class NetworkDelegate;
15 class DnsCertProvenanceChecker; 16 class DnsCertProvenanceChecker;
16 class HttpTransactionFactory; 17 class HttpTransactionFactory;
17 } // namespace net 18 } // namespace net
18 19
19 class ProfileImplIOData : public ProfileIOData { 20 class ProfileImplIOData : public ProfileIOData {
20 public: 21 public:
21 class Handle { 22 class Handle {
22 public: 23 public:
23 explicit Handle(Profile* profile); 24 explicit Handle(Profile* profile);
24 ~Handle(); 25 ~Handle();
25 26
26 bool HasMainRequestContext() const { 27 bool HasMainRequestContext() const {
27 return main_request_context_getter_ != NULL; 28 return main_request_context_getter_ != NULL;
28 } 29 }
29 30
30 // Init() must be called before ~Handle(). It records all the necessary 31 // Init() must be called before ~Handle(). It records all the necessary
31 // parameters needed to construct a ChromeURLRequestContextGetter. 32 // parameters needed to construct a ChromeURLRequestContextGetter.
32 void Init(const FilePath& cookie_path, 33 void Init(const FilePath& cookie_path,
33 const FilePath& cache_path, 34 const FilePath& cache_path,
34 int cache_max_size, 35 int cache_max_size,
35 const FilePath& media_cache_path, 36 const FilePath& media_cache_path,
36 int media_cache_max_size, 37 int media_cache_max_size,
37 const FilePath& extensions_cookie_path); 38 const FilePath& extensions_cookie_path);
38 39
40 // Called on-demand for each isolated app.
41 void InitIsolatedApp(const Extension* installed_app,
42 const FilePath& cookie_path,
43 const FilePath& cache_path,
44 int cache_max_size);
45
39 scoped_refptr<ChromeURLRequestContextGetter> 46 scoped_refptr<ChromeURLRequestContextGetter>
40 GetMainRequestContextGetter() const; 47 GetMainRequestContextGetter() const;
41 scoped_refptr<ChromeURLRequestContextGetter> 48 scoped_refptr<ChromeURLRequestContextGetter>
42 GetMediaRequestContextGetter() const; 49 GetMediaRequestContextGetter() const;
43 scoped_refptr<ChromeURLRequestContextGetter> 50 scoped_refptr<ChromeURLRequestContextGetter>
44 GetExtensionsRequestContextGetter() const; 51 GetExtensionsRequestContextGetter() const;
52 scoped_refptr<ChromeURLRequestContextGetter>
53 GetIsolatedAppRequestContextGetter(
54 const Extension* installed_app) const;
45 55
46 private: 56 private:
57 typedef base::hash_map<std::string,
58 scoped_refptr<ChromeURLRequestContextGetter> >
59 ChromeURLRequestContextGetterMap;
60
47 // Lazily initialize ProfileParams. We do this on the calls to 61 // Lazily initialize ProfileParams. We do this on the calls to
48 // Get*RequestContextGetter(), so we only initialize ProfileParams right 62 // Get*RequestContextGetter(), so we only initialize ProfileParams right
49 // before posting a task to the IO thread to start using them. This prevents 63 // before posting a task to the IO thread to start using them. This prevents
50 // objects that are supposed to be deleted on the IO thread, but are created 64 // objects that are supposed to be deleted on the IO thread, but are created
51 // on the UI thread from being unnecessarily initialized. 65 // on the UI thread from being unnecessarily initialized.
52 void LazyInitialize() const; 66 void LazyInitialize() const;
53 67
54 // Ordering is important here. Do not reorder unless you know what you're 68 // Ordering is important here. Do not reorder unless you know what you're
55 // doing. We need to release |io_data_| *before* the getters, because we 69 // doing. We need to release |io_data_| *before* the getters, because we
56 // want to make sure that the last reference for |io_data_| is on the IO 70 // want to make sure that the last reference for |io_data_| is on the IO
57 // thread. The getters will be deleted on the IO thread, so they will 71 // thread. The getters will be deleted on the IO thread, so they will
58 // release their refs to their contexts, which will release the last refs to 72 // release their refs to their contexts, which will release the last refs to
59 // the ProfileIOData on the IO thread. 73 // the ProfileIOData on the IO thread.
60 mutable scoped_refptr<ChromeURLRequestContextGetter> 74 mutable scoped_refptr<ChromeURLRequestContextGetter>
61 main_request_context_getter_; 75 main_request_context_getter_;
62 mutable scoped_refptr<ChromeURLRequestContextGetter> 76 mutable scoped_refptr<ChromeURLRequestContextGetter>
63 media_request_context_getter_; 77 media_request_context_getter_;
64 mutable scoped_refptr<ChromeURLRequestContextGetter> 78 mutable scoped_refptr<ChromeURLRequestContextGetter>
65 extensions_request_context_getter_; 79 extensions_request_context_getter_;
80 mutable ChromeURLRequestContextGetterMap app_request_context_getter_map_;
66 const scoped_refptr<ProfileImplIOData> io_data_; 81 const scoped_refptr<ProfileImplIOData> io_data_;
67 82
68 Profile* const profile_; 83 Profile* const profile_;
69 84
70 mutable bool initialized_; 85 mutable bool initialized_;
71 86
72 DISALLOW_COPY_AND_ASSIGN(Handle); 87 DISALLOW_COPY_AND_ASSIGN(Handle);
73 }; 88 };
74 89
75 private: 90 private:
76 friend class base::RefCountedThreadSafe<ProfileImplIOData>; 91 friend class base::RefCountedThreadSafe<ProfileImplIOData>;
77 92
78 struct LazyParams { 93 struct LazyParams {
79 LazyParams(); 94 LazyParams();
80 ~LazyParams(); 95 ~LazyParams();
81 96
82 // All of these parameters are intended to be read on the IO thread. 97 // All of these parameters are intended to be read on the IO thread.
83 FilePath cookie_path; 98 FilePath cookie_path;
84 FilePath cache_path; 99 FilePath cache_path;
85 int cache_max_size; 100 int cache_max_size;
86 FilePath media_cache_path; 101 FilePath media_cache_path;
87 int media_cache_max_size; 102 int media_cache_max_size;
88 FilePath extensions_cookie_path; 103 FilePath extensions_cookie_path;
89 IOThread* io_thread; 104 IOThread* io_thread;
90 105
91 ProfileParams profile_params; 106 ProfileParams profile_params;
92 }; 107 };
93 108
109 typedef base::hash_map<std::string, LazyParams*> LazyParamsMap;
110
94 ProfileImplIOData(); 111 ProfileImplIOData();
95 virtual ~ProfileImplIOData(); 112 virtual ~ProfileImplIOData();
96 113
97 // Lazily initializes ProfileImplIOData. 114 // Lazily initializes ProfileImplIOData.
98 virtual void LazyInitializeInternal() const; 115 virtual void LazyInitializeInternal() const;
116 virtual scoped_refptr<RequestContext> InitializeAppRequestContext(
117 scoped_refptr<ChromeURLRequestContext> main_context,
118 const Extension *installed_app) const;
99 virtual scoped_refptr<ChromeURLRequestContext> 119 virtual scoped_refptr<ChromeURLRequestContext>
100 AcquireMainRequestContext() const; 120 AcquireMainRequestContext() const;
101 virtual scoped_refptr<ChromeURLRequestContext> 121 virtual scoped_refptr<ChromeURLRequestContext>
102 AcquireMediaRequestContext() const; 122 AcquireMediaRequestContext() const;
103 virtual scoped_refptr<ChromeURLRequestContext> 123 virtual scoped_refptr<ChromeURLRequestContext>
104 AcquireExtensionsRequestContext() const; 124 AcquireExtensionsRequestContext() const;
125 virtual scoped_refptr<ChromeURLRequestContext>
126 AcquireIsolatedAppRequestContext(
127 scoped_refptr<ChromeURLRequestContext> main_context,
128 const Extension* installed_app) const;
105 129
106 // Lazy initialization params. 130 // Lazy initialization params.
107 mutable scoped_ptr<LazyParams> lazy_params_; 131 mutable scoped_ptr<LazyParams> lazy_params_;
108 132
133 // One LazyParams per isolated app.
134 mutable LazyParamsMap lazy_params_map_;
135
109 mutable scoped_refptr<RequestContext> main_request_context_; 136 mutable scoped_refptr<RequestContext> main_request_context_;
110 mutable scoped_refptr<RequestContext> media_request_context_; 137 mutable scoped_refptr<RequestContext> media_request_context_;
111 mutable scoped_refptr<RequestContext> extensions_request_context_; 138 mutable scoped_refptr<RequestContext> extensions_request_context_;
112 139
113 mutable scoped_ptr<net::NetworkDelegate> network_delegate_; 140 mutable scoped_ptr<net::NetworkDelegate> network_delegate_;
114 mutable scoped_ptr<net::DnsCertProvenanceChecker> dns_cert_checker_; 141 mutable scoped_ptr<net::DnsCertProvenanceChecker> dns_cert_checker_;
115 mutable scoped_ptr<net::HttpTransactionFactory> main_http_factory_; 142 mutable scoped_ptr<net::HttpTransactionFactory> main_http_factory_;
116 mutable scoped_ptr<net::HttpTransactionFactory> media_http_factory_; 143 mutable scoped_ptr<net::HttpTransactionFactory> media_http_factory_;
117 144
118 DISALLOW_COPY_AND_ASSIGN(ProfileImplIOData); 145 DISALLOW_COPY_AND_ASSIGN(ProfileImplIOData);
119 }; 146 };
120 147
121 #endif // CHROME_BROWSER_PROFILES_PROFILE_IMPL_IO_DATA_H_ 148 #endif // CHROME_BROWSER_PROFILES_PROFILE_IMPL_IO_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698