| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include "chrome/browser/net/chrome_url_request_context.h" | 5 #include "chrome/browser/net/chrome_url_request_context.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/privacy_blacklist/blacklist.h" | 10 #include "chrome/browser/privacy_blacklist/blacklist.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 context->ftp_transaction_factory_ = | 148 context->ftp_transaction_factory_ = |
| 149 new net::FtpNetworkLayer(context->host_resolver_); | 149 new net::FtpNetworkLayer(context->host_resolver_); |
| 150 #else | 150 #else |
| 151 context->ftp_transaction_factory_ = | 151 context->ftp_transaction_factory_ = |
| 152 new net::FtpNetworkLayer(context->host_resolver_); | 152 new net::FtpNetworkLayer(context->host_resolver_); |
| 153 #endif | 153 #endif |
| 154 | 154 |
| 155 // setup cookie store | 155 // setup cookie store |
| 156 if (!context->cookie_store_) { | 156 if (!context->cookie_store_) { |
| 157 DCHECK(!cookie_store_path.empty()); | 157 DCHECK(!cookie_store_path.empty()); |
| 158 context->cookie_db_.reset(new SQLitePersistentCookieStore( | 158 |
| 159 cookie_store_path.ToWStringHack(), | 159 scoped_refptr<SQLitePersistentCookieStore> cookie_db = |
| 160 g_browser_process->db_thread()->message_loop())); | 160 new SQLitePersistentCookieStore( |
| 161 context->cookie_store_ = new net::CookieMonster(context->cookie_db_.get()); | 161 cookie_store_path.ToWStringHack(), |
| 162 g_browser_process->db_thread()->message_loop()); |
| 163 context->cookie_store_ = new net::CookieMonster(cookie_db.get()); |
| 162 } | 164 } |
| 163 | 165 |
| 164 return context; | 166 return context; |
| 165 } | 167 } |
| 166 | 168 |
| 167 // static | 169 // static |
| 168 ChromeURLRequestContext* ChromeURLRequestContext::CreateOriginalForMedia( | 170 ChromeURLRequestContext* ChromeURLRequestContext::CreateOriginalForMedia( |
| 169 Profile* profile, const FilePath& disk_cache_path, int cache_size) { | 171 Profile* profile, const FilePath& disk_cache_path, int cache_size) { |
| 170 DCHECK(!profile->IsOffTheRecord()); | 172 DCHECK(!profile->IsOffTheRecord()); |
| 171 return CreateRequestContextForMedia(profile, disk_cache_path, cache_size, | 173 return CreateRequestContextForMedia(profile, disk_cache_path, cache_size, |
| 172 false); | 174 false); |
| 173 } | 175 } |
| 174 | 176 |
| 175 // static | 177 // static |
| 176 ChromeURLRequestContext* ChromeURLRequestContext::CreateOriginalForExtensions( | 178 ChromeURLRequestContext* ChromeURLRequestContext::CreateOriginalForExtensions( |
| 177 Profile* profile, const FilePath& cookie_store_path) { | 179 Profile* profile, const FilePath& cookie_store_path) { |
| 178 DCHECK(!profile->IsOffTheRecord()); | 180 DCHECK(!profile->IsOffTheRecord()); |
| 179 ChromeURLRequestContext* context = new ChromeURLRequestContext(profile); | 181 ChromeURLRequestContext* context = new ChromeURLRequestContext(profile); |
| 180 | 182 |
| 181 // All we care about for extensions is the cookie store. | 183 // All we care about for extensions is the cookie store. |
| 182 DCHECK(!cookie_store_path.empty()); | 184 DCHECK(!cookie_store_path.empty()); |
| 183 context->cookie_db_.reset(new SQLitePersistentCookieStore( | 185 |
| 184 cookie_store_path.ToWStringHack(), | 186 scoped_refptr<SQLitePersistentCookieStore> cookie_db = |
| 185 g_browser_process->db_thread()->message_loop())); | 187 new SQLitePersistentCookieStore( |
| 186 net::CookieMonster* cookie_monster = new net::CookieMonster( | 188 cookie_store_path.ToWStringHack(), |
| 187 context->cookie_db_.get()); | 189 g_browser_process->db_thread()->message_loop()); |
| 190 net::CookieMonster* cookie_monster = new net::CookieMonster(cookie_db.get()); |
| 188 | 191 |
| 189 // Enable cookies for extension URLs only. | 192 // Enable cookies for extension URLs only. |
| 190 const char* schemes[] = {chrome::kExtensionScheme}; | 193 const char* schemes[] = {chrome::kExtensionScheme}; |
| 191 cookie_monster->SetCookieableSchemes(schemes, 1); | 194 cookie_monster->SetCookieableSchemes(schemes, 1); |
| 192 context->cookie_store_ = cookie_monster; | 195 context->cookie_store_ = cookie_monster; |
| 193 | 196 |
| 194 return context; | 197 return context; |
| 195 } | 198 } |
| 196 | 199 |
| 197 // static | 200 // static |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 ChromeURLRequestContext::~ChromeURLRequestContext() { | 538 ChromeURLRequestContext::~ChromeURLRequestContext() { |
| 536 DCHECK(NULL == prefs_); | 539 DCHECK(NULL == prefs_); |
| 537 | 540 |
| 538 NotificationService::current()->Notify( | 541 NotificationService::current()->Notify( |
| 539 NotificationType::URL_REQUEST_CONTEXT_RELEASED, | 542 NotificationType::URL_REQUEST_CONTEXT_RELEASED, |
| 540 Source<URLRequestContext>(this), | 543 Source<URLRequestContext>(this), |
| 541 NotificationService::NoDetails()); | 544 NotificationService::NoDetails()); |
| 542 | 545 |
| 543 delete ftp_transaction_factory_; | 546 delete ftp_transaction_factory_; |
| 544 delete http_transaction_factory_; | 547 delete http_transaction_factory_; |
| 545 | |
| 546 // Do not delete the cookie store in the case of the media context, as it is | |
| 547 // owned by the original context. | |
| 548 // TODO(eroman): The lifetime expectation of cookie_store_ is not right. | |
| 549 // The assumption here is that the original request context (which owns | |
| 550 // cookie_store_) is going to outlive the media context (which uses it). | |
| 551 // However based on the destruction order of profiles this is not true. | |
| 552 // http://crbug.com/15289. | |
| 553 if (!is_media_) | |
| 554 delete cookie_store_; | |
| 555 } | 548 } |
| OLD | NEW |