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

Unified Diff: chrome/browser/profile.cc

Issue 115204: Add a separate cookie store that's used for extensions.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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/profile.cc
===================================================================
--- chrome/browser/profile.cc (revision 15945)
+++ chrome/browser/profile.cc (working copy)
@@ -34,6 +34,7 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/net/cookie_monster_sqlite.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/render_messages.h"
@@ -49,6 +50,16 @@
// Profile::GetDefaultRequestContext.
URLRequestContext* Profile::default_request_context_;
+static void CleanupRequestContext(ChromeURLRequestContext* context) {
+ if (context) {
+ context->CleanupOnUIThread();
+
+ // Clean up request context on IO thread.
+ g_browser_process->io_thread()->message_loop()->ReleaseSoon(FROM_HERE,
+ context);
+ }
+}
+
// static
void Profile::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterBooleanPref(prefs::kSearchSuggestEnabled, true);
@@ -89,6 +100,7 @@
explicit OffTheRecordProfileImpl(Profile* real_profile)
: profile_(real_profile),
media_request_context_(NULL),
+ extensions_request_context_(NULL),
start_time_(Time::Now()) {
request_context_ = ChromeURLRequestContext::CreateOffTheRecord(this);
request_context_->AddRef();
@@ -105,15 +117,9 @@
}
virtual ~OffTheRecordProfileImpl() {
- if (request_context_) {
- request_context_->CleanupOnUIThread();
-
- // Clean up request context on IO thread.
- g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
- NewRunnableMethod(request_context_,
- &base::RefCountedThreadSafe<URLRequestContext>::Release));
- request_context_ = NULL;
- }
+ CleanupRequestContext(request_context_);
+ CleanupRequestContext(media_request_context_);
+ CleanupRequestContext(extensions_request_context_);
NotificationService::current()->RemoveObserver(
this,
NotificationType::BROWSER_CLOSED,
@@ -251,6 +257,18 @@
return media_request_context_;
}
+ URLRequestContext* GetRequestContextForExtensions() {
+ if (!extensions_request_context_) {
+ extensions_request_context_ =
+ ChromeURLRequestContext::CreateOffTheRecordForExtensions(this);
+ extensions_request_context_->AddRef();
+
+ DCHECK(extensions_request_context_->cookie_store());
+ }
+
+ return extensions_request_context_;
+ }
+
virtual SessionService* GetSessionService() {
// Don't save any sessions when off the record.
return NULL;
@@ -358,6 +376,8 @@
// The context for requests for media resources.
ChromeURLRequestContext* media_request_context_;
+ ChromeURLRequestContext* extensions_request_context_;
+
// The download manager that only stores downloaded items in memory.
scoped_refptr<DownloadManager> download_manager_;
@@ -382,6 +402,7 @@
: path_(path),
request_context_(NULL),
media_request_context_(NULL),
+ extensions_request_context_(NULL),
history_service_created_(false),
created_web_data_service_(false),
created_download_manager_(false),
@@ -508,29 +529,13 @@
spellchecker_->Release();
}
- if (request_context_) {
- request_context_->CleanupOnUIThread();
+ if (default_request_context_ == request_context_)
+ default_request_context_ = NULL;
- if (default_request_context_ == request_context_)
- default_request_context_ = NULL;
+ CleanupRequestContext(request_context_);
+ CleanupRequestContext(media_request_context_);
+ CleanupRequestContext(extensions_request_context_);
- // Clean up request context on IO thread.
- g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
- NewRunnableMethod(request_context_,
- &base::RefCountedThreadSafe<URLRequestContext>::Release));
- request_context_ = NULL;
- }
-
- if (media_request_context_) {
- media_request_context_->CleanupOnUIThread();
-
- // Clean up request context on IO thread.
- g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
- NewRunnableMethod(media_request_context_,
- &base::RefCountedThreadSafe<URLRequestContext>::Release));
- media_request_context_ = NULL;
- }
-
// HistoryService may call into the BookmarkModel, as such we need to
// delete HistoryService before the BookmarkModel. The destructor for
// HistoryService will join with HistoryService's backend thread so that
@@ -709,6 +714,21 @@
return media_request_context_;
}
+URLRequestContext* ProfileImpl::GetRequestContextForExtensions() {
+ if (!extensions_request_context_) {
+ FilePath cookie_path = GetPath();
+ cookie_path = cookie_path.Append(chrome::kExtensionsCookieFilename);
+
+ extensions_request_context_ =
+ ChromeURLRequestContext::CreateOriginalForExtensions(this, cookie_path);
+ extensions_request_context_->AddRef();
+
+ DCHECK(extensions_request_context_->cookie_store());
+ }
+
+ return extensions_request_context_;
+}
+
HistoryService* ProfileImpl::GetHistoryService(ServiceAccessType sat) {
if (!history_service_created_) {
history_service_created_ = true;

Powered by Google App Engine
This is Rietveld 408576698