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" |
(...skipping 22 matching lines...) Expand all Loading... |
33 } | 33 } |
34 | 34 |
35 virtual void TearDown() OVERRIDE { | 35 virtual void TearDown() OVERRIDE { |
36 context_.reset(); | 36 context_.reset(); |
37 base::RunLoop().RunUntilIdle(); | 37 base::RunLoop().RunUntilIdle(); |
38 } | 38 } |
39 | 39 |
40 class RegistrationListener : public ServiceWorkerRegistration::Listener { | 40 class RegistrationListener : public ServiceWorkerRegistration::Listener { |
41 public: | 41 public: |
42 RegistrationListener() {} | 42 RegistrationListener() {} |
43 ~RegistrationListener() {} | 43 ~RegistrationListener() { |
| 44 if (observed_registration_) |
| 45 observed_registration_->RemoveListener(this); |
| 46 } |
44 | 47 |
45 virtual void OnVersionAttributesChanged( | 48 virtual void OnVersionAttributesChanged( |
46 ServiceWorkerRegistration* registration, | 49 ServiceWorkerRegistration* registration, |
47 ChangedVersionAttributesMask changed_mask, | 50 ChangedVersionAttributesMask changed_mask, |
48 const ServiceWorkerRegistrationInfo& info) OVERRIDE { | 51 const ServiceWorkerRegistrationInfo& info) OVERRIDE { |
49 observed_registration_ = registration; | 52 observed_registration_ = registration; |
50 observed_changed_mask_ = changed_mask; | 53 observed_changed_mask_ = changed_mask; |
51 observed_info_ = info; | 54 observed_info_ = info; |
52 } | 55 } |
53 | 56 |
| 57 virtual void OnRegistrationFailed( |
| 58 ServiceWorkerRegistration* registration) OVERRIDE { |
| 59 NOTREACHED(); |
| 60 } |
| 61 |
54 void Reset() { | 62 void Reset() { |
55 observed_registration_ = NULL; | 63 observed_registration_ = NULL; |
56 observed_changed_mask_ = ChangedVersionAttributesMask(); | 64 observed_changed_mask_ = ChangedVersionAttributesMask(); |
57 observed_info_ = ServiceWorkerRegistrationInfo(); | 65 observed_info_ = ServiceWorkerRegistrationInfo(); |
58 } | 66 } |
59 | 67 |
60 scoped_refptr<ServiceWorkerRegistration> observed_registration_; | 68 scoped_refptr<ServiceWorkerRegistration> observed_registration_; |
61 ChangedVersionAttributesMask observed_changed_mask_; | 69 ChangedVersionAttributesMask observed_changed_mask_; |
62 ServiceWorkerRegistrationInfo observed_info_; | 70 ServiceWorkerRegistrationInfo observed_info_; |
63 }; | 71 }; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 EXPECT_FALSE(registration->waiting_version()); | 140 EXPECT_FALSE(registration->waiting_version()); |
133 EXPECT_EQ(ChangedVersionAttributesMask::WAITING_VERSION, | 141 EXPECT_EQ(ChangedVersionAttributesMask::WAITING_VERSION, |
134 listener.observed_changed_mask_.changed()); | 142 listener.observed_changed_mask_.changed()); |
135 EXPECT_EQ(version_1_id, listener.observed_info_.active_version.version_id); | 143 EXPECT_EQ(version_1_id, listener.observed_info_.active_version.version_id); |
136 EXPECT_TRUE(listener.observed_info_.waiting_version.is_null); | 144 EXPECT_TRUE(listener.observed_info_.waiting_version.is_null); |
137 EXPECT_TRUE(listener.observed_info_.installing_version.is_null); | 145 EXPECT_TRUE(listener.observed_info_.installing_version.is_null); |
138 EXPECT_TRUE(listener.observed_info_.controlling_version.is_null); | 146 EXPECT_TRUE(listener.observed_info_.controlling_version.is_null); |
139 } | 147 } |
140 | 148 |
141 } // namespace content | 149 } // namespace content |
OLD | NEW |