OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
10 #include "content/browser/browser_thread_impl.h" | 10 #include "content/browser/browser_thread_impl.h" |
11 #include "content/browser/appcache/chrome_appcache_service.h" | 11 #include "content/browser/appcache/chrome_appcache_service.h" |
| 12 #include "content/test/test_browser_context.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "webkit/appcache/appcache_database.h" | 14 #include "webkit/appcache/appcache_database.h" |
14 #include "webkit/appcache/appcache_storage_impl.h" | 15 #include "webkit/appcache/appcache_storage_impl.h" |
15 #include "webkit/appcache/appcache_test_helper.h" | 16 #include "webkit/appcache/appcache_test_helper.h" |
16 #include "webkit/quota/mock_special_storage_policy.h" | 17 #include "webkit/quota/mock_special_storage_policy.h" |
17 | 18 |
18 #include <set> | 19 #include <set> |
19 | 20 |
20 using content::BrowserThread; | 21 using content::BrowserThread; |
21 using content::BrowserThreadImpl; | 22 using content::BrowserThreadImpl; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 ScopedTempDir temp_dir_; | 59 ScopedTempDir temp_dir_; |
59 const GURL kProtectedManifestURL; | 60 const GURL kProtectedManifestURL; |
60 const GURL kNormalManifestURL; | 61 const GURL kNormalManifestURL; |
61 const GURL kSessionOnlyManifestURL; | 62 const GURL kSessionOnlyManifestURL; |
62 | 63 |
63 private: | 64 private: |
64 BrowserThreadImpl file_thread_; | 65 BrowserThreadImpl file_thread_; |
65 BrowserThreadImpl file_user_blocking_thread_; | 66 BrowserThreadImpl file_user_blocking_thread_; |
66 BrowserThreadImpl cache_thread_; | 67 BrowserThreadImpl cache_thread_; |
67 BrowserThreadImpl io_thread_; | 68 BrowserThreadImpl io_thread_; |
| 69 TestBrowserContext browser_context_; |
68 }; | 70 }; |
69 | 71 |
70 scoped_refptr<ChromeAppCacheService> | 72 scoped_refptr<ChromeAppCacheService> |
71 ChromeAppCacheServiceTest::CreateAppCacheService( | 73 ChromeAppCacheServiceTest::CreateAppCacheService( |
72 const FilePath& appcache_path, | 74 const FilePath& appcache_path, |
73 bool init_storage) { | 75 bool init_storage) { |
74 scoped_refptr<ChromeAppCacheService> appcache_service = | 76 scoped_refptr<ChromeAppCacheService> appcache_service = |
75 new ChromeAppCacheService(NULL); | 77 new ChromeAppCacheService(NULL); |
76 content::ResourceContext* resource_context = NULL; | |
77 scoped_refptr<quota::MockSpecialStoragePolicy> mock_policy = | 78 scoped_refptr<quota::MockSpecialStoragePolicy> mock_policy = |
78 new quota::MockSpecialStoragePolicy; | 79 new quota::MockSpecialStoragePolicy; |
79 mock_policy->AddProtected(kProtectedManifestURL.GetOrigin()); | 80 mock_policy->AddProtected(kProtectedManifestURL.GetOrigin()); |
80 mock_policy->AddSessionOnly(kSessionOnlyManifestURL.GetOrigin()); | 81 mock_policy->AddSessionOnly(kSessionOnlyManifestURL.GetOrigin()); |
81 BrowserThread::PostTask( | 82 BrowserThread::PostTask( |
82 BrowserThread::IO, FROM_HERE, | 83 BrowserThread::IO, FROM_HERE, |
83 base::Bind(&ChromeAppCacheService::InitializeOnIOThread, | 84 base::Bind(&ChromeAppCacheService::InitializeOnIOThread, |
84 appcache_service.get(), appcache_path, resource_context, | 85 appcache_service.get(), appcache_path, |
85 mock_policy)); | 86 browser_context_.GetResourceContext(), mock_policy)); |
86 // Steps needed to initialize the storage of AppCache data. | 87 // Steps needed to initialize the storage of AppCache data. |
87 message_loop_.RunAllPending(); | 88 message_loop_.RunAllPending(); |
88 if (init_storage) { | 89 if (init_storage) { |
89 appcache::AppCacheStorageImpl* storage = | 90 appcache::AppCacheStorageImpl* storage = |
90 static_cast<appcache::AppCacheStorageImpl*>( | 91 static_cast<appcache::AppCacheStorageImpl*>( |
91 appcache_service->storage()); | 92 appcache_service->storage()); |
92 storage->database_->db_connection(); | 93 storage->database_->db_connection(); |
93 storage->disk_cache(); | 94 storage->disk_cache(); |
94 message_loop_.RunAllPending(); | 95 message_loop_.RunAllPending(); |
95 } | 96 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 EXPECT_TRUE(origins.find(kNormalManifestURL.GetOrigin()) != origins.end()); | 223 EXPECT_TRUE(origins.find(kNormalManifestURL.GetOrigin()) != origins.end()); |
223 EXPECT_TRUE(origins.find(kSessionOnlyManifestURL.GetOrigin()) != | 224 EXPECT_TRUE(origins.find(kSessionOnlyManifestURL.GetOrigin()) != |
224 origins.end()); | 225 origins.end()); |
225 | 226 |
226 // Delete and let cleanup tasks run prior to returning. | 227 // Delete and let cleanup tasks run prior to returning. |
227 appcache_service = NULL; | 228 appcache_service = NULL; |
228 message_loop_.RunAllPending(); | 229 message_loop_.RunAllPending(); |
229 } | 230 } |
230 | 231 |
231 } // namespace appcache | 232 } // namespace appcache |
OLD | NEW |