OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/service_worker/service_worker_registration.h" | 5 #include "content/browser/service_worker/service_worker_registration.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
12 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
13 #include "content/browser/service_worker/service_worker_context_core.h" | 14 #include "content/browser/service_worker/service_worker_context_core.h" |
14 #include "content/browser/service_worker/service_worker_registration_handle.h" | 15 #include "content/browser/service_worker/service_worker_registration_handle.h" |
15 #include "content/public/test/test_browser_thread_bundle.h" | 16 #include "content/public/test/test_browser_thread_bundle.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "url/gurl.h" | 18 #include "url/gurl.h" |
18 | 19 |
19 namespace content { | 20 namespace content { |
20 | 21 |
21 class ServiceWorkerRegistrationTest : public testing::Test { | 22 class ServiceWorkerRegistrationTest : public testing::Test { |
22 public: | 23 public: |
23 ServiceWorkerRegistrationTest() | 24 ServiceWorkerRegistrationTest() |
24 : thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {} | 25 : thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {} |
25 | 26 |
26 void SetUp() override { | 27 void SetUp() override { |
27 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager( | 28 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager( |
28 new MockServiceWorkerDatabaseTaskManager( | 29 new MockServiceWorkerDatabaseTaskManager( |
29 base::ThreadTaskRunnerHandle::Get())); | 30 base::ThreadTaskRunnerHandle::Get())); |
30 context_.reset( | 31 context_.reset(new ServiceWorkerContextCore( |
31 new ServiceWorkerContextCore(base::FilePath(), | 32 base::FilePath(), std::move(database_task_manager), |
32 database_task_manager.Pass(), | 33 base::ThreadTaskRunnerHandle::Get(), NULL, NULL, NULL, NULL)); |
33 base::ThreadTaskRunnerHandle::Get(), | |
34 NULL, | |
35 NULL, | |
36 NULL, | |
37 NULL)); | |
38 context_ptr_ = context_->AsWeakPtr(); | 34 context_ptr_ = context_->AsWeakPtr(); |
39 } | 35 } |
40 | 36 |
41 void TearDown() override { | 37 void TearDown() override { |
42 context_.reset(); | 38 context_.reset(); |
43 base::RunLoop().RunUntilIdle(); | 39 base::RunLoop().RunUntilIdle(); |
44 } | 40 } |
45 | 41 |
46 class RegistrationListener : public ServiceWorkerRegistration::Listener { | 42 class RegistrationListener : public ServiceWorkerRegistration::Listener { |
47 public: | 43 public: |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 scoped_ptr<ServiceWorkerRegistrationHandle> handle( | 163 scoped_ptr<ServiceWorkerRegistrationHandle> handle( |
168 new ServiceWorkerRegistrationHandle( | 164 new ServiceWorkerRegistrationHandle( |
169 context_ptr_, | 165 context_ptr_, |
170 base::WeakPtr<ServiceWorkerProviderHost>(), | 166 base::WeakPtr<ServiceWorkerProviderHost>(), |
171 registration.get())); | 167 registration.get())); |
172 registration->NotifyRegistrationFailed(); | 168 registration->NotifyRegistrationFailed(); |
173 // Don't crash when handle gets destructed. | 169 // Don't crash when handle gets destructed. |
174 } | 170 } |
175 | 171 |
176 } // namespace content | 172 } // namespace content |
OLD | NEW |