summaryrefslogtreecommitdiffstats
path: root/content/browser/appcache
diff options
context:
space:
mode:
authormichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-15 05:12:34 +0000
committermichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-15 05:12:34 +0000
commit55c0ecae62d3e95bf016510d8cb00fdcc6c7271e (patch)
tree7657cef41f5f1487f095437c39c45dfc2b979f0d /content/browser/appcache
parent7dc57d7e28303ebee22ca59528f4ee22b64b54a9 (diff)
downloadchromium_src-55c0ecae62d3e95bf016510d8cb00fdcc6c7271e.zip
chromium_src-55c0ecae62d3e95bf016510d8cb00fdcc6c7271e.tar.gz
chromium_src-55c0ecae62d3e95bf016510d8cb00fdcc6c7271e.tar.bz2
AppCache and StoragePartition'ing
* Get rid of BrowserContext::GetAppCacheService and ResourceContext::GetAppCacheService as they've been replace by accessors on the StoragePartition and WorkerStoragePartition classes. * Added a BrowsingContext::GetRequestContextForStoragePartition(id) accessor so the constellation of storage context + main request context can initialized properly. Implemented that method in chrome's Profile class in terms of the existing GetRequestContextForIsolatedApp(id) accessor. * Hold references to the ChromeAppCacheService and ChromeBlobStorageContext inside of ResourceMessageFilter and provide accessors to them. These are for use by the ResourceDispatcherHost singleton which would otherwise not have enough context to get needed references to partitioned things. * Widen the ResourceDispatcherHostDelegate::RequestBeginning method to also take an AppCacheService* parameter since that value can no longer be retrieved via the ResourceContext. Chrome's impl of this delegate interface needs that value to construct OfflineResourceThrottles. * Poke at WorkerProcessHost to create ResourceMessageFilters and others to utlize the correct URLRequestContext so the right set of cookies are used in shared workers. TBR=mihaip,sail,thakis BUG=85121 Review URL: https://chromiumcodereview.appspot.com/10916132 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156991 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/appcache')
-rw-r--r--content/browser/appcache/chrome_appcache_service.cc11
-rw-r--r--content/browser/appcache/chrome_appcache_service.h5
-rw-r--r--content/browser/appcache/chrome_appcache_service_unittest.cc35
3 files changed, 49 insertions, 2 deletions
diff --git a/content/browser/appcache/chrome_appcache_service.cc b/content/browser/appcache/chrome_appcache_service.cc
index c4512b0..9508b80 100644
--- a/content/browser/appcache/chrome_appcache_service.cc
+++ b/content/browser/appcache/chrome_appcache_service.cc
@@ -9,6 +9,8 @@
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/resource_context.h"
#include "net/base/net_errors.h"
+#include "net/url_request/url_request_context_getter.h"
+#include "webkit/appcache/appcache_storage_impl.h"
#include "webkit/quota/quota_manager.h"
using content::BrowserThread;
@@ -22,12 +24,19 @@ ChromeAppCacheService::ChromeAppCacheService(
void ChromeAppCacheService::InitializeOnIOThread(
const FilePath& cache_path,
content::ResourceContext* resource_context,
+ net::URLRequestContextGetter* request_context_getter,
scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
cache_path_ = cache_path;
resource_context_ = resource_context;
- set_request_context(resource_context->GetRequestContext());
+
+ // The |request_context_getter| can be NULL in some unit tests.
+ // TODO(awong): TestProfile is difficult to work with. The
+ // SafeBrowsing tests require that GetRequestContext return NULL
+ // so we can't depend on having a non-NULL value here. See crbug/149783.
+ if (request_context_getter)
+ set_request_context(request_context_getter->GetURLRequestContext());
// Init our base class.
Initialize(
diff --git a/content/browser/appcache/chrome_appcache_service.h b/content/browser/appcache/chrome_appcache_service.h
index 68d5ebe..6bc4ac2 100644
--- a/content/browser/appcache/chrome_appcache_service.h
+++ b/content/browser/appcache/chrome_appcache_service.h
@@ -16,6 +16,10 @@
class FilePath;
+namespace net {
+class URLRequestContextGetter;
+}
+
namespace content {
class ResourceContext;
}
@@ -44,6 +48,7 @@ class CONTENT_EXPORT ChromeAppCacheService
void InitializeOnIOThread(
const FilePath& cache_path, // may be empty to use in-memory structures
content::ResourceContext* resource_context,
+ net::URLRequestContextGetter* request_context_getter,
scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy);
// AppCachePolicy overrides
diff --git a/content/browser/appcache/chrome_appcache_service_unittest.cc b/content/browser/appcache/chrome_appcache_service_unittest.cc
index f9f50d1..70419b2 100644
--- a/content/browser/appcache/chrome_appcache_service_unittest.cc
+++ b/content/browser/appcache/chrome_appcache_service_unittest.cc
@@ -9,7 +9,9 @@
#include "base/scoped_temp_dir.h"
#include "content/browser/browser_thread_impl.h"
#include "content/browser/appcache/chrome_appcache_service.h"
+#include "content/public/browser/resource_context.h"
#include "content/public/test/test_browser_context.h"
+#include "net/url_request/url_request_context_getter.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/appcache/appcache_database.h"
#include "webkit/appcache/appcache_storage_impl.h"
@@ -31,6 +33,31 @@ const char kProtectedManifest[] = "http://www.protected.com/cache.manifest";
const char kNormalManifest[] = "http://www.normal.com/cache.manifest";
const char kSessionOnlyManifest[] = "http://www.sessiononly.com/cache.manifest";
+class MockURLRequestContextGetter : public net::URLRequestContextGetter {
+ public:
+ MockURLRequestContextGetter(
+ net::URLRequestContext* context,
+ base::MessageLoopProxy* message_loop_proxy)
+ : context_(context), message_loop_proxy_(message_loop_proxy) {
+ }
+
+ virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE {
+ return context_;
+ }
+
+ virtual scoped_refptr<base::SingleThreadTaskRunner>
+ GetNetworkTaskRunner() const OVERRIDE {
+ return message_loop_proxy_;
+ }
+
+ protected:
+ virtual ~MockURLRequestContextGetter() {}
+
+ private:
+ net::URLRequestContext* context_;
+ scoped_refptr<base::SingleThreadTaskRunner> message_loop_proxy_;
+};
+
} // namespace
namespace appcache {
@@ -79,11 +106,17 @@ ChromeAppCacheServiceTest::CreateAppCacheService(
new quota::MockSpecialStoragePolicy;
mock_policy->AddProtected(kProtectedManifestURL.GetOrigin());
mock_policy->AddSessionOnly(kSessionOnlyManifestURL.GetOrigin());
+ scoped_refptr<MockURLRequestContextGetter> mock_request_context_getter =
+ new MockURLRequestContextGetter(
+ browser_context_.GetResourceContext()->GetRequestContext(),
+ message_loop_.message_loop_proxy());
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&ChromeAppCacheService::InitializeOnIOThread,
appcache_service.get(), appcache_path,
- browser_context_.GetResourceContext(), mock_policy));
+ browser_context_.GetResourceContext(),
+ mock_request_context_getter,
+ mock_policy));
// Steps needed to initialize the storage of AppCache data.
message_loop_.RunAllPending();
if (init_storage) {