| 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 "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "base/thread_task_runner_handle.h" | 11 #include "base/thread_task_runner_handle.h" |
| 12 #include "content/browser/browser_thread_impl.h" | 12 #include "content/browser/browser_thread_impl.h" |
| 13 #include "content/browser/service_worker/service_worker_context_core.h" | 13 #include "content/browser/service_worker/service_worker_context_core.h" |
| 14 #include "content/browser/service_worker/service_worker_registration_handle.h" | 14 #include "content/browser/service_worker/service_worker_registration_handle.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 | 19 |
| 20 class ServiceWorkerRegistrationTest : public testing::Test { | 20 class ServiceWorkerRegistrationTest : public testing::Test { |
| 21 public: | 21 public: |
| 22 ServiceWorkerRegistrationTest() | 22 ServiceWorkerRegistrationTest() |
| 23 : io_thread_(BrowserThread::IO, &message_loop_) {} | 23 : io_thread_(BrowserThread::IO, &message_loop_) {} |
| 24 | 24 |
| 25 virtual void SetUp() override { | 25 void SetUp() override { |
| 26 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager( | 26 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager( |
| 27 new MockServiceWorkerDatabaseTaskManager( | 27 new MockServiceWorkerDatabaseTaskManager( |
| 28 base::ThreadTaskRunnerHandle::Get())); | 28 base::ThreadTaskRunnerHandle::Get())); |
| 29 context_.reset( | 29 context_.reset( |
| 30 new ServiceWorkerContextCore(base::FilePath(), | 30 new ServiceWorkerContextCore(base::FilePath(), |
| 31 base::ThreadTaskRunnerHandle::Get(), | 31 base::ThreadTaskRunnerHandle::Get(), |
| 32 database_task_manager.Pass(), | 32 database_task_manager.Pass(), |
| 33 base::ThreadTaskRunnerHandle::Get(), | 33 base::ThreadTaskRunnerHandle::Get(), |
| 34 NULL, | 34 NULL, |
| 35 NULL, | 35 NULL, |
| 36 NULL, | 36 NULL, |
| 37 NULL)); | 37 NULL)); |
| 38 context_ptr_ = context_->AsWeakPtr(); | 38 context_ptr_ = context_->AsWeakPtr(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 virtual void TearDown() override { | 41 void TearDown() override { |
| 42 context_.reset(); | 42 context_.reset(); |
| 43 base::RunLoop().RunUntilIdle(); | 43 base::RunLoop().RunUntilIdle(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 class RegistrationListener : public ServiceWorkerRegistration::Listener { | 46 class RegistrationListener : public ServiceWorkerRegistration::Listener { |
| 47 public: | 47 public: |
| 48 RegistrationListener() {} | 48 RegistrationListener() {} |
| 49 ~RegistrationListener() { | 49 ~RegistrationListener() { |
| 50 if (observed_registration_.get()) | 50 if (observed_registration_.get()) |
| 51 observed_registration_->RemoveListener(this); | 51 observed_registration_->RemoveListener(this); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 scoped_ptr<ServiceWorkerRegistrationHandle> handle( | 172 scoped_ptr<ServiceWorkerRegistrationHandle> handle( |
| 173 new ServiceWorkerRegistrationHandle(context_ptr_, | 173 new ServiceWorkerRegistrationHandle(context_ptr_, |
| 174 NULL, | 174 NULL, |
| 175 kProviderId, | 175 kProviderId, |
| 176 registration.get())); | 176 registration.get())); |
| 177 registration->NotifyRegistrationFailed(); | 177 registration->NotifyRegistrationFailed(); |
| 178 // Don't crash when handle gets destructed. | 178 // Don't crash when handle gets destructed. |
| 179 } | 179 } |
| 180 | 180 |
| 181 } // namespace content | 181 } // namespace content |
| OLD | NEW |