OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/files/scoped_temp_dir.h" | 5 #include "base/files/scoped_temp_dir.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "content/browser/browser_thread_impl.h" | 8 #include "content/browser/browser_thread_impl.h" |
9 #include "content/browser/fileapi/mock_url_request_delegate.h" | 9 #include "content/browser/fileapi/mock_url_request_delegate.h" |
10 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 10 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 void EmptyCallback() {} | 28 void EmptyCallback() {} |
29 | 29 |
30 } | 30 } |
31 | 31 |
32 class ServiceWorkerContextRequestHandlerTest : public testing::Test { | 32 class ServiceWorkerContextRequestHandlerTest : public testing::Test { |
33 public: | 33 public: |
34 ServiceWorkerContextRequestHandlerTest() | 34 ServiceWorkerContextRequestHandlerTest() |
35 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {} | 35 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {} |
36 | 36 |
37 virtual void SetUp() OVERRIDE { | 37 virtual void SetUp() override { |
38 helper_.reset(new EmbeddedWorkerTestHelper(kMockRenderProcessId)); | 38 helper_.reset(new EmbeddedWorkerTestHelper(kMockRenderProcessId)); |
39 | 39 |
40 // A new unstored registration/version. | 40 // A new unstored registration/version. |
41 scope_ = GURL("http://host/scope/"); | 41 scope_ = GURL("http://host/scope/"); |
42 script_url_ = GURL("http://host/script.js"); | 42 script_url_ = GURL("http://host/script.js"); |
43 registration_ = new ServiceWorkerRegistration( | 43 registration_ = new ServiceWorkerRegistration( |
44 scope_, 1L, context()->AsWeakPtr()); | 44 scope_, 1L, context()->AsWeakPtr()); |
45 version_ = new ServiceWorkerVersion( | 45 version_ = new ServiceWorkerVersion( |
46 registration_.get(), script_url_, 1L, context()->AsWeakPtr()); | 46 registration_.get(), script_url_, 1L, context()->AsWeakPtr()); |
47 | 47 |
48 // An empty host. | 48 // An empty host. |
49 scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( | 49 scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( |
50 kMockRenderProcessId, 1 /* provider_id */, | 50 kMockRenderProcessId, 1 /* provider_id */, |
51 context()->AsWeakPtr(), NULL)); | 51 context()->AsWeakPtr(), NULL)); |
52 provider_host_ = host->AsWeakPtr(); | 52 provider_host_ = host->AsWeakPtr(); |
53 context()->AddProviderHost(host.Pass()); | 53 context()->AddProviderHost(host.Pass()); |
54 | 54 |
55 context()->storage()->LazyInitialize(base::Bind(&EmptyCallback)); | 55 context()->storage()->LazyInitialize(base::Bind(&EmptyCallback)); |
56 base::RunLoop().RunUntilIdle(); | 56 base::RunLoop().RunUntilIdle(); |
57 } | 57 } |
58 | 58 |
59 virtual void TearDown() OVERRIDE { | 59 virtual void TearDown() override { |
60 version_ = NULL; | 60 version_ = NULL; |
61 registration_ = NULL; | 61 registration_ = NULL; |
62 helper_.reset(); | 62 helper_.reset(); |
63 } | 63 } |
64 | 64 |
65 ServiceWorkerContextCore* context() const { return helper_->context(); } | 65 ServiceWorkerContextCore* context() const { return helper_->context(); } |
66 | 66 |
67 protected: | 67 protected: |
68 TestBrowserThreadBundle browser_thread_bundle_; | 68 TestBrowserThreadBundle browser_thread_bundle_; |
69 scoped_ptr<EmbeddedWorkerTestHelper> helper_; | 69 scoped_ptr<EmbeddedWorkerTestHelper> helper_; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 handler->MaybeCreateJob(request.get(), NULL); | 131 handler->MaybeCreateJob(request.get(), NULL); |
132 ASSERT_TRUE(job.get()); | 132 ASSERT_TRUE(job.get()); |
133 ServiceWorkerWriteToCacheJob* sw_job = | 133 ServiceWorkerWriteToCacheJob* sw_job = |
134 static_cast<ServiceWorkerWriteToCacheJob*>(job.get()); | 134 static_cast<ServiceWorkerWriteToCacheJob*>(job.get()); |
135 | 135 |
136 // Verify the net request is initialized to bypass the browser cache. | 136 // Verify the net request is initialized to bypass the browser cache. |
137 EXPECT_TRUE(sw_job->net_request_->load_flags() & net::LOAD_BYPASS_CACHE); | 137 EXPECT_TRUE(sw_job->net_request_->load_flags() & net::LOAD_BYPASS_CACHE); |
138 } | 138 } |
139 | 139 |
140 } // namespace content | 140 } // namespace content |
OLD | NEW |