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

Side by Side Diff: content/browser/appcache/chrome_appcache_service_unittest.cc

Issue 1170623003: Revert "content: Remove use of MessageLoopProxy and deprecated MessageLoop APIs" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 unified diff | Download patch
OLDNEW
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/files/file_util.h" 6 #include "base/files/file_util.h"
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/location.h"
9 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
10 #include "base/single_thread_task_runner.h" 9 #include "base/message_loop/message_loop.h"
11 #include "content/browser/appcache/appcache_database.h" 10 #include "content/browser/appcache/appcache_database.h"
12 #include "content/browser/appcache/appcache_storage_impl.h" 11 #include "content/browser/appcache/appcache_storage_impl.h"
13 #include "content/browser/appcache/chrome_appcache_service.h" 12 #include "content/browser/appcache/chrome_appcache_service.h"
14 #include "content/browser/browser_thread_impl.h" 13 #include "content/browser/browser_thread_impl.h"
15 #include "content/public/browser/resource_context.h" 14 #include "content/public/browser/resource_context.h"
16 #include "content/public/test/mock_special_storage_policy.h" 15 #include "content/public/test/mock_special_storage_policy.h"
17 #include "content/public/test/test_browser_context.h" 16 #include "content/public/test/test_browser_context.h"
18 #include "content/test/appcache_test_helper.h" 17 #include "content/test/appcache_test_helper.h"
19 #include "net/url_request/url_request_context_getter.h" 18 #include "net/url_request/url_request_context_getter.h"
20 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
21 20
22 #include <set> 21 #include <set>
23 22
24 namespace content { 23 namespace content {
25 namespace { 24 namespace {
26 const base::FilePath::CharType kTestingAppCacheDirname[] = 25 const base::FilePath::CharType kTestingAppCacheDirname[] =
27 FILE_PATH_LITERAL("Application Cache"); 26 FILE_PATH_LITERAL("Application Cache");
28 27
29 // 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
30 // test. 29 // test.
31 const char kProtectedManifest[] = "http://www.protected.com/cache.manifest"; 30 const char kProtectedManifest[] = "http://www.protected.com/cache.manifest";
32 const char kNormalManifest[] = "http://www.normal.com/cache.manifest"; 31 const char kNormalManifest[] = "http://www.normal.com/cache.manifest";
33 const char kSessionOnlyManifest[] = "http://www.sessiononly.com/cache.manifest"; 32 const char kSessionOnlyManifest[] = "http://www.sessiononly.com/cache.manifest";
34 33
35 class MockURLRequestContextGetter : public net::URLRequestContextGetter { 34 class MockURLRequestContextGetter : public net::URLRequestContextGetter {
36 public: 35 public:
37 MockURLRequestContextGetter(net::URLRequestContext* context, 36 MockURLRequestContextGetter(
38 base::SingleThreadTaskRunner* task_runner) 37 net::URLRequestContext* context,
39 : context_(context), task_runner_(task_runner) {} 38 base::MessageLoopProxy* message_loop_proxy)
39 : context_(context), message_loop_proxy_(message_loop_proxy) {
40 }
40 41
41 net::URLRequestContext* GetURLRequestContext() override { return context_; } 42 net::URLRequestContext* GetURLRequestContext() override { return context_; }
42 43
43 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() 44 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner()
44 const override { 45 const override {
45 return task_runner_; 46 return message_loop_proxy_;
46 } 47 }
47 48
48 protected: 49 protected:
49 ~MockURLRequestContextGetter() override {} 50 ~MockURLRequestContextGetter() override {}
50 51
51 private: 52 private:
52 net::URLRequestContext* context_; 53 net::URLRequestContext* context_;
53 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 54 scoped_refptr<base::SingleThreadTaskRunner> message_loop_proxy_;
54 }; 55 };
55 56
56 } // namespace 57 } // namespace
57 58
58 class ChromeAppCacheServiceTest : public testing::Test { 59 class ChromeAppCacheServiceTest : public testing::Test {
59 public: 60 public:
60 ChromeAppCacheServiceTest() 61 ChromeAppCacheServiceTest()
61 : kProtectedManifestURL(kProtectedManifest), 62 : kProtectedManifestURL(kProtectedManifest),
62 kNormalManifestURL(kNormalManifest), 63 kNormalManifestURL(kNormalManifest),
63 kSessionOnlyManifestURL(kSessionOnlyManifest), 64 kSessionOnlyManifestURL(kSessionOnlyManifest),
(...skipping 29 matching lines...) Expand all
93 bool init_storage) { 94 bool init_storage) {
94 scoped_refptr<ChromeAppCacheService> appcache_service = 95 scoped_refptr<ChromeAppCacheService> appcache_service =
95 new ChromeAppCacheService(NULL); 96 new ChromeAppCacheService(NULL);
96 scoped_refptr<MockSpecialStoragePolicy> mock_policy = 97 scoped_refptr<MockSpecialStoragePolicy> mock_policy =
97 new MockSpecialStoragePolicy; 98 new MockSpecialStoragePolicy;
98 mock_policy->AddProtected(kProtectedManifestURL.GetOrigin()); 99 mock_policy->AddProtected(kProtectedManifestURL.GetOrigin());
99 mock_policy->AddSessionOnly(kSessionOnlyManifestURL.GetOrigin()); 100 mock_policy->AddSessionOnly(kSessionOnlyManifestURL.GetOrigin());
100 scoped_refptr<MockURLRequestContextGetter> mock_request_context_getter = 101 scoped_refptr<MockURLRequestContextGetter> mock_request_context_getter =
101 new MockURLRequestContextGetter( 102 new MockURLRequestContextGetter(
102 browser_context_.GetResourceContext()->GetRequestContext(), 103 browser_context_.GetResourceContext()->GetRequestContext(),
103 message_loop_.task_runner().get()); 104 message_loop_.message_loop_proxy().get());
104 BrowserThread::PostTask( 105 BrowserThread::PostTask(
105 BrowserThread::IO, 106 BrowserThread::IO,
106 FROM_HERE, 107 FROM_HERE,
107 base::Bind(&ChromeAppCacheService::InitializeOnIOThread, 108 base::Bind(&ChromeAppCacheService::InitializeOnIOThread,
108 appcache_service.get(), 109 appcache_service.get(),
109 appcache_path, 110 appcache_path,
110 browser_context_.GetResourceContext(), 111 browser_context_.GetResourceContext(),
111 mock_request_context_getter, 112 mock_request_context_getter,
112 mock_policy)); 113 mock_policy));
113 // Steps needed to initialize the storage of AppCache data. 114 // Steps needed to initialize the storage of AppCache data.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 EXPECT_TRUE(origins.find(kNormalManifestURL.GetOrigin()) != origins.end()); 212 EXPECT_TRUE(origins.find(kNormalManifestURL.GetOrigin()) != origins.end());
212 EXPECT_TRUE(origins.find(kSessionOnlyManifestURL.GetOrigin()) != 213 EXPECT_TRUE(origins.find(kSessionOnlyManifestURL.GetOrigin()) !=
213 origins.end()); 214 origins.end());
214 215
215 // Delete and let cleanup tasks run prior to returning. 216 // Delete and let cleanup tasks run prior to returning.
216 appcache_service = NULL; 217 appcache_service = NULL;
217 message_loop_.RunUntilIdle(); 218 message_loop_.RunUntilIdle();
218 } 219 }
219 220
220 } // namespace content 221 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_url_request_job_unittest.cc ('k') | content/browser/appcache/mock_appcache_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698