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

Unified Diff: chrome/browser/profiles/profile_impl.cc

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, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/profiles/profile_impl.cc
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index 22e3911ff890380575f3a058670c883ba2d9f6bf..de8f9d52f6aec582e3665c4d6e55202054179ba4 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -816,6 +816,17 @@ URLRequestContextGetter* ProfileImpl::GetRequestContext() {
return request_context;
}
+URLRequestContextGetter* ProfileImpl::GetRequestContextForPossibleApp(
+ const Extension* installed_app) {
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableExperimentalAppManifests) &&
+ installed_app != NULL &&
+ installed_app->is_storage_isolated())
+ return GetRequestContextForIsolatedApp(installed_app);
+
+ return GetRequestContext();
+}
+
URLRequestContextGetter* ProfileImpl::GetRequestContextForMedia() {
return io_data_.GetMediaRequestContextGetter();
}
@@ -833,6 +844,35 @@ URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() {
return io_data_.GetExtensionsRequestContextGetter();
}
+URLRequestContextGetter* ProfileImpl::GetRequestContextForIsolatedApp(
+ const Extension* installed_app) {
+ // Create a request context specific to this app on demand.
+ FilePath app_path = GetPath().Append(chrome::kIsolatedAppStateDirname);
willchan no longer on Chromium 2011/03/03 18:16:59 How about add app_path as a parameter to the Handl
Charlie Reis 2011/03/04 22:34:53 Fixed. Much cleaner.
+ app_path = app_path.AppendASCII(installed_app->id());
+ FilePath cookie_path = app_path.Append(chrome::kCookieFilename);
+ FilePath cache_path = app_path.Append(chrome::kCacheDirname);
+
+ // Create the paths if they don't yet exist.
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE,
+ NewRunnableFunction(&ProfileImpl::CreateIsolatedAppPaths,
Matt Perry 2011/03/03 22:59:21 Are these paths accessed only on the file thread?
Charlie Reis 2011/03/04 22:34:53 I was under the impression all file I/O had to be
Charlie Reis 2011/03/04 23:49:41 Hmm, looks like you may be right, Matt: http://bui
Matt Perry 2011/03/04 23:53:53 I think you might just have to do it earlier in st
Charlie Reis 2011/03/08 00:56:48 I'm uneasy about creating the path when the app is
Charlie Reis 2011/03/08 02:34:04 Ugh. It's a known issue and isn't likely to be fi
Charlie Reis 2011/03/08 20:44:41 Chatted with rdsmith@, and we agreed that the dire
+ app_path,
+ cache_path));
+
+ // Initialize the app context IO data on demand.
+ // TODO(creis): Determine the correct cache size.
+ io_data_.InitIsolatedApp(installed_app, cookie_path, cache_path, 0);
+
+ return io_data_.GetIsolatedAppRequestContextGetter(installed_app);
+}
+
+void ProfileImpl::CreateIsolatedAppPaths(const FilePath& app_path,
+ const FilePath& cache_path) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ file_util::CreateDirectory(app_path);
+ file_util::CreateDirectory(cache_path);
+}
+
void ProfileImpl::RegisterExtensionWithRequestContexts(
const Extension* extension) {
// AddRef to ensure the data lives until the other thread gets it. Balanced in

Powered by Google App Engine
This is Rietveld 408576698