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

Side by Side Diff: chrome/browser/profiles/off_the_record_profile_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_OFF_THE_RECORD_PROFILE_IO_DATA_H_ 5 #ifndef CHROME_BROWSER_PROFILES_OFF_THE_RECORD_PROFILE_IO_DATA_H_
6 #define CHROME_BROWSER_PROFILES_OFF_THE_RECORD_PROFILE_IO_DATA_H_ 6 #define CHROME_BROWSER_PROFILES_OFF_THE_RECORD_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"
11 #include "base/hash_tables.h"
11 #include "base/ref_counted.h" 12 #include "base/ref_counted.h"
12 #include "base/scoped_ptr.h" 13 #include "base/scoped_ptr.h"
13 #include "chrome/browser/profiles/profile_io_data.h" 14 #include "chrome/browser/profiles/profile_io_data.h"
14 15
15 class ChromeURLRequestContext; 16 class ChromeURLRequestContext;
16 class ChromeURLRequestContextGetter; 17 class ChromeURLRequestContextGetter;
18 class Extension;
17 class IOThread; 19 class IOThread;
18 class Profile; 20 class Profile;
19 21
20 // OffTheRecordProfile owns a OffTheRecordProfileIOData::Handle, which holds a 22 // OffTheRecordProfile owns a OffTheRecordProfileIOData::Handle, which holds a
21 // reference to the OffTheRecordProfileIOData. OffTheRecordProfileIOData is 23 // reference to the OffTheRecordProfileIOData. OffTheRecordProfileIOData is
22 // intended to own all the objects owned by OffTheRecordProfile which live on 24 // intended to own all the objects owned by OffTheRecordProfile which live on
23 // the IO thread, such as, but not limited to, network objects like 25 // the IO thread, such as, but not limited to, network objects like
24 // CookieMonster, HttpTransactionFactory, etc. OffTheRecordProfileIOData is 26 // CookieMonster, HttpTransactionFactory, etc. OffTheRecordProfileIOData is
25 // owned by the OffTheRecordProfile and OffTheRecordProfileIOData's 27 // owned by the OffTheRecordProfile and OffTheRecordProfileIOData's
26 // ChromeURLRequestContexts. When all of them go away, then ProfileIOData will 28 // ChromeURLRequestContexts. When all of them go away, then ProfileIOData will
27 // be deleted. Note that the OffTheRecordProfileIOData will typically outlive 29 // be deleted. Note that the OffTheRecordProfileIOData will typically outlive
28 // the Profile it is "owned" by, so it's important for OffTheRecordProfileIOData 30 // the Profile it is "owned" by, so it's important for OffTheRecordProfileIOData
29 // not to hold any references to the Profile beyond what's used by LazyParams 31 // not to hold any references to the Profile beyond what's used by LazyParams
30 // (which should be deleted after lazy initialization). 32 // (which should be deleted after lazy initialization).
31 33
32 class OffTheRecordProfileIOData : public ProfileIOData { 34 class OffTheRecordProfileIOData : public ProfileIOData {
33 public: 35 public:
34 class Handle { 36 class Handle {
35 public: 37 public:
36 explicit Handle(Profile* profile); 38 explicit Handle(Profile* profile);
37 ~Handle(); 39 ~Handle();
38 40
39 scoped_refptr<ChromeURLRequestContextGetter> 41 scoped_refptr<ChromeURLRequestContextGetter>
40 GetMainRequestContextGetter() const; 42 GetMainRequestContextGetter() const;
41 scoped_refptr<ChromeURLRequestContextGetter> 43 scoped_refptr<ChromeURLRequestContextGetter>
42 GetExtensionsRequestContextGetter() const; 44 GetExtensionsRequestContextGetter() const;
45 scoped_refptr<ChromeURLRequestContextGetter>
46 GetIsolatedAppRequestContextGetter(
47 const Extension* installed_app) const;
43 48
44 private: 49 private:
50 typedef base::hash_map<std::string,
51 scoped_refptr<ChromeURLRequestContextGetter> >
52 ChromeURLRequestContextGetterMap;
53
45 // Lazily initialize ProfileParams. We do this on the calls to 54 // Lazily initialize ProfileParams. We do this on the calls to
46 // Get*RequestContextGetter(), so we only initialize ProfileParams right 55 // Get*RequestContextGetter(), so we only initialize ProfileParams right
47 // before posting a task to the IO thread to start using them. This prevents 56 // before posting a task to the IO thread to start using them. This prevents
48 // objects that are supposed to be deleted on the IO thread, but are created 57 // objects that are supposed to be deleted on the IO thread, but are created
49 // on the UI thread from being unnecessarily initialized. 58 // on the UI thread from being unnecessarily initialized.
50 void LazyInitialize() const; 59 void LazyInitialize() const;
51 60
52 // Ordering is important here. Do not reorder unless you know what you're 61 // Ordering is important here. Do not reorder unless you know what you're
53 // doing. We need to release |io_data_| *before* the getters, because we 62 // doing. We need to release |io_data_| *before* the getters, because we
54 // want to make sure that the last reference for |io_data_| is on the IO 63 // want to make sure that the last reference for |io_data_| is on the IO
55 // thread. The getters will be deleted on the IO thread, so they will 64 // thread. The getters will be deleted on the IO thread, so they will
56 // release their refs to their contexts, which will release the last refs to 65 // release their refs to their contexts, which will release the last refs to
57 // the ProfileIOData on the IO thread. 66 // the ProfileIOData on the IO thread.
58 mutable scoped_refptr<ChromeURLRequestContextGetter> 67 mutable scoped_refptr<ChromeURLRequestContextGetter>
59 main_request_context_getter_; 68 main_request_context_getter_;
60 mutable scoped_refptr<ChromeURLRequestContextGetter> 69 mutable scoped_refptr<ChromeURLRequestContextGetter>
61 extensions_request_context_getter_; 70 extensions_request_context_getter_;
71 mutable ChromeURLRequestContextGetterMap
72 app_request_context_getter_map_;
62 const scoped_refptr<OffTheRecordProfileIOData> io_data_; 73 const scoped_refptr<OffTheRecordProfileIOData> io_data_;
63 74
64 Profile* const profile_; 75 Profile* const profile_;
65 76
66 mutable bool initialized_; 77 mutable bool initialized_;
67 78
68 DISALLOW_COPY_AND_ASSIGN(Handle); 79 DISALLOW_COPY_AND_ASSIGN(Handle);
69 }; 80 };
70 81
71 private: 82 private:
72 friend class base::RefCountedThreadSafe<OffTheRecordProfileIOData>; 83 friend class base::RefCountedThreadSafe<OffTheRecordProfileIOData>;
73 84
74 struct LazyParams { 85 struct LazyParams {
75 LazyParams(); 86 LazyParams();
76 ~LazyParams(); 87 ~LazyParams();
77 88
78 IOThread* io_thread; 89 IOThread* io_thread;
79 ProfileParams profile_params; 90 ProfileParams profile_params;
80 }; 91 };
81 92
82 OffTheRecordProfileIOData(); 93 OffTheRecordProfileIOData();
83 ~OffTheRecordProfileIOData(); 94 ~OffTheRecordProfileIOData();
84 95
85 // Lazily initializes ProfileIOData. 96 // Lazily initializes ProfileIOData.
86 virtual void LazyInitializeInternal() const; 97 virtual void LazyInitializeInternal() const;
98 virtual scoped_refptr<RequestContext> InitializeAppRequestContext(
99 scoped_refptr<ChromeURLRequestContext> main_context,
100 const Extension *installed_app) const;
87 virtual scoped_refptr<ChromeURLRequestContext> 101 virtual scoped_refptr<ChromeURLRequestContext>
88 AcquireMainRequestContext() const; 102 AcquireMainRequestContext() const;
89 virtual scoped_refptr<ChromeURLRequestContext> 103 virtual scoped_refptr<ChromeURLRequestContext>
90 AcquireMediaRequestContext() const; 104 AcquireMediaRequestContext() const;
91 virtual scoped_refptr<ChromeURLRequestContext> 105 virtual scoped_refptr<ChromeURLRequestContext>
92 AcquireExtensionsRequestContext() const; 106 AcquireExtensionsRequestContext() const;
107 virtual scoped_refptr<ChromeURLRequestContext>
108 AcquireIsolatedAppRequestContext(
109 scoped_refptr<ChromeURLRequestContext> main_context,
110 const Extension* installed_app) const;
93 111
94 // Lazy initialization params. 112 // Lazy initialization params.
95 mutable scoped_ptr<LazyParams> lazy_params_; 113 mutable scoped_ptr<LazyParams> lazy_params_;
96 114
97 mutable bool initialized_; 115 mutable bool initialized_;
98 mutable scoped_refptr<RequestContext> main_request_context_; 116 mutable scoped_refptr<RequestContext> main_request_context_;
99 // NOTE: |media_request_context_| just points to the same context that 117 // NOTE: |media_request_context_| just points to the same context that
100 // |main_request_context_| points to. 118 // |main_request_context_| points to.
101 mutable scoped_refptr<RequestContext> media_request_context_; 119 mutable scoped_refptr<RequestContext> media_request_context_;
102 mutable scoped_refptr<RequestContext> extensions_request_context_; 120 mutable scoped_refptr<RequestContext> extensions_request_context_;
103 121
104 mutable scoped_ptr<net::NetworkDelegate> network_delegate_; 122 mutable scoped_ptr<net::NetworkDelegate> network_delegate_;
105 mutable scoped_ptr<net::DnsCertProvenanceChecker> dns_cert_checker_; 123 mutable scoped_ptr<net::DnsCertProvenanceChecker> dns_cert_checker_;
106 mutable scoped_ptr<net::HttpTransactionFactory> main_http_factory_; 124 mutable scoped_ptr<net::HttpTransactionFactory> main_http_factory_;
107 125
108 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileIOData); 126 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileIOData);
109 }; 127 };
110 128
111 #endif // CHROME_BROWSER_PROFILES_OFF_THE_RECORD_PROFILE_IO_DATA_H_ 129 #endif // CHROME_BROWSER_PROFILES_OFF_THE_RECORD_PROFILE_IO_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698