| 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 "content/browser/browser_thread_impl.h" | 10 #include "content/browser/browser_thread_impl.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 scoped_refptr<ServiceWorkerRegistration> registration = | 52 scoped_refptr<ServiceWorkerRegistration> registration = |
| 53 new ServiceWorkerRegistration( | 53 new ServiceWorkerRegistration( |
| 54 GURL("http://www.example.com/*"), | 54 GURL("http://www.example.com/*"), |
| 55 GURL("http://www.example.com/service_worker.js"), | 55 GURL("http://www.example.com/service_worker.js"), |
| 56 registration_id); | 56 registration_id); |
| 57 | 57 |
| 58 const int64 version_1_id = 1L; | 58 const int64 version_1_id = 1L; |
| 59 const int64 version_2_id = 2L; | 59 const int64 version_2_id = 2L; |
| 60 scoped_refptr<ServiceWorkerVersion> version_1 = | 60 scoped_refptr<ServiceWorkerVersion> version_1 = |
| 61 new ServiceWorkerVersion(registration, NULL, version_1_id); | 61 new ServiceWorkerVersion(registration, NULL, version_1_id); |
| 62 version_1->set_status(ServiceWorkerVersion::ACTIVE); |
| 62 registration->set_active_version(version_1); | 63 registration->set_active_version(version_1); |
| 63 | 64 |
| 64 scoped_refptr<ServiceWorkerVersion> version_2 = | 65 scoped_refptr<ServiceWorkerVersion> version_2 = |
| 65 new ServiceWorkerVersion(registration, NULL, version_2_id); | 66 new ServiceWorkerVersion(registration, NULL, version_2_id); |
| 66 registration->set_pending_version(version_2); | 67 registration->set_pending_version(version_2); |
| 67 | 68 |
| 68 registration->ActivatePendingVersion(); | 69 registration->ActivatePendingVersion(); |
| 69 DCHECK_EQ(version_2, registration->active_version()); | 70 DCHECK_EQ(version_2, registration->active_version()); |
| 70 DCHECK(version_1->is_shutdown()); | 71 DCHECK(version_1->is_shutdown()); |
| 71 DCHECK(version_1->HasOneRef()); | 72 DCHECK(version_1->HasOneRef()); |
| 72 version_1 = NULL; | 73 version_1 = NULL; |
| 73 | 74 |
| 74 DCHECK(!version_2->is_shutdown()); | 75 DCHECK(!version_2->is_shutdown()); |
| 75 DCHECK(!version_2->HasOneRef()); | 76 DCHECK(!version_2->HasOneRef()); |
| 76 | 77 |
| 77 registration->Shutdown(); | 78 registration->Shutdown(); |
| 78 | 79 |
| 79 DCHECK(registration->is_shutdown()); | 80 DCHECK(registration->is_shutdown()); |
| 80 DCHECK(version_2->is_shutdown()); | 81 DCHECK(version_2->is_shutdown()); |
| 81 DCHECK(registration->HasOneRef()); | 82 DCHECK(registration->HasOneRef()); |
| 82 DCHECK(version_2->HasOneRef()); | 83 DCHECK(version_2->HasOneRef()); |
| 83 } | 84 } |
| 84 | 85 |
| 85 } // namespace content | 86 } // namespace content |
| OLD | NEW |