OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "content/browser/appcache/chrome_appcache_service.h" | 10 #include "content/browser/appcache/chrome_appcache_service.h" |
11 #include "content/browser/browser_thread_impl.h" | 11 #include "content/browser/browser_thread_impl.h" |
12 #include "content/public/browser/resource_context.h" | 12 #include "content/public/browser/resource_context.h" |
| 13 #include "content/public/test/mock_special_storage_policy.h" |
13 #include "content/public/test/test_browser_context.h" | 14 #include "content/public/test/test_browser_context.h" |
14 #include "content/test/appcache_test_helper.h" | 15 #include "content/test/appcache_test_helper.h" |
15 #include "net/url_request/url_request_context_getter.h" | 16 #include "net/url_request/url_request_context_getter.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "webkit/browser/appcache/appcache_database.h" | 18 #include "webkit/browser/appcache/appcache_database.h" |
18 #include "webkit/browser/appcache/appcache_storage_impl.h" | 19 #include "webkit/browser/appcache/appcache_storage_impl.h" |
19 #include "webkit/browser/quota/mock_special_storage_policy.h" | |
20 | 20 |
21 #include <set> | 21 #include <set> |
22 | 22 |
23 namespace content { | 23 namespace content { |
24 namespace { | 24 namespace { |
25 const base::FilePath::CharType kTestingAppCacheDirname[] = | 25 const base::FilePath::CharType kTestingAppCacheDirname[] = |
26 FILE_PATH_LITERAL("Application Cache"); | 26 FILE_PATH_LITERAL("Application Cache"); |
27 | 27 |
28 // Examples of a protected and an unprotected origin, to be used througout the | 28 // Examples of a protected and an unprotected origin, to be used througout the |
29 // test. | 29 // test. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 BrowserThreadImpl io_thread_; | 89 BrowserThreadImpl io_thread_; |
90 TestBrowserContext browser_context_; | 90 TestBrowserContext browser_context_; |
91 }; | 91 }; |
92 | 92 |
93 scoped_refptr<ChromeAppCacheService> | 93 scoped_refptr<ChromeAppCacheService> |
94 ChromeAppCacheServiceTest::CreateAppCacheService( | 94 ChromeAppCacheServiceTest::CreateAppCacheService( |
95 const base::FilePath& appcache_path, | 95 const base::FilePath& appcache_path, |
96 bool init_storage) { | 96 bool init_storage) { |
97 scoped_refptr<ChromeAppCacheService> appcache_service = | 97 scoped_refptr<ChromeAppCacheService> appcache_service = |
98 new ChromeAppCacheService(NULL); | 98 new ChromeAppCacheService(NULL); |
99 scoped_refptr<quota::MockSpecialStoragePolicy> mock_policy = | 99 scoped_refptr<MockSpecialStoragePolicy> mock_policy = |
100 new quota::MockSpecialStoragePolicy; | 100 new MockSpecialStoragePolicy; |
101 mock_policy->AddProtected(kProtectedManifestURL.GetOrigin()); | 101 mock_policy->AddProtected(kProtectedManifestURL.GetOrigin()); |
102 mock_policy->AddSessionOnly(kSessionOnlyManifestURL.GetOrigin()); | 102 mock_policy->AddSessionOnly(kSessionOnlyManifestURL.GetOrigin()); |
103 scoped_refptr<MockURLRequestContextGetter> mock_request_context_getter = | 103 scoped_refptr<MockURLRequestContextGetter> mock_request_context_getter = |
104 new MockURLRequestContextGetter( | 104 new MockURLRequestContextGetter( |
105 browser_context_.GetResourceContext()->GetRequestContext(), | 105 browser_context_.GetResourceContext()->GetRequestContext(), |
106 message_loop_.message_loop_proxy().get()); | 106 message_loop_.message_loop_proxy().get()); |
107 BrowserThread::PostTask( | 107 BrowserThread::PostTask( |
108 BrowserThread::IO, | 108 BrowserThread::IO, |
109 FROM_HERE, | 109 FROM_HERE, |
110 base::Bind(&ChromeAppCacheService::InitializeOnIOThread, | 110 base::Bind(&ChromeAppCacheService::InitializeOnIOThread, |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 EXPECT_TRUE(origins.find(kNormalManifestURL.GetOrigin()) != origins.end()); | 214 EXPECT_TRUE(origins.find(kNormalManifestURL.GetOrigin()) != origins.end()); |
215 EXPECT_TRUE(origins.find(kSessionOnlyManifestURL.GetOrigin()) != | 215 EXPECT_TRUE(origins.find(kSessionOnlyManifestURL.GetOrigin()) != |
216 origins.end()); | 216 origins.end()); |
217 | 217 |
218 // Delete and let cleanup tasks run prior to returning. | 218 // Delete and let cleanup tasks run prior to returning. |
219 appcache_service = NULL; | 219 appcache_service = NULL; |
220 message_loop_.RunUntilIdle(); | 220 message_loop_.RunUntilIdle(); |
221 } | 221 } |
222 | 222 |
223 } // namespace content | 223 } // namespace content |
OLD | NEW |