Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/devtools/protocol/service_worker_handler.h" | 5 #include "content/browser/devtools/protocol/service_worker_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/containers/scoped_ptr_hash_map.h" | |
| 8 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 9 #include "content/browser/devtools/service_worker_devtools_agent_host.h" | 10 #include "content/browser/devtools/service_worker_devtools_agent_host.h" |
| 10 #include "content/browser/devtools/service_worker_devtools_manager.h" | 11 #include "content/browser/devtools/service_worker_devtools_manager.h" |
| 11 #include "content/browser/service_worker/service_worker_context_observer.h" | 12 #include "content/browser/service_worker/service_worker_context_observer.h" |
| 12 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 13 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 14 #include "content/browser/service_worker/service_worker_version.h" | |
| 13 #include "content/public/browser/browser_context.h" | 15 #include "content/public/browser/browser_context.h" |
| 14 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/devtools_agent_host.h" | 17 #include "content/public/browser/devtools_agent_host.h" |
| 16 #include "content/public/browser/render_frame_host.h" | 18 #include "content/public/browser/render_frame_host.h" |
| 17 #include "content/public/browser/render_process_host.h" | 19 #include "content/public/browser/render_process_host.h" |
| 18 #include "content/public/browser/storage_partition.h" | 20 #include "content/public/browser/storage_partition.h" |
| 19 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 20 | 22 |
| 21 // Windows headers will redefine SendMessage. | 23 // Windows headers will redefine SendMessage. |
| 22 #ifdef SendMessage | 24 #ifdef SendMessage |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 ->set_status(GetVersionStatusString(version_info.status))); | 78 ->set_status(GetVersionStatusString(version_info.status))); |
| 77 return version; | 79 return version; |
| 78 } | 80 } |
| 79 | 81 |
| 80 scoped_refptr<ServiceWorkerRegistration> CreateRegistrationDictionaryValue( | 82 scoped_refptr<ServiceWorkerRegistration> CreateRegistrationDictionaryValue( |
| 81 const ServiceWorkerRegistrationInfo& registration_info) { | 83 const ServiceWorkerRegistrationInfo& registration_info) { |
| 82 scoped_refptr<ServiceWorkerRegistration> registration( | 84 scoped_refptr<ServiceWorkerRegistration> registration( |
| 83 ServiceWorkerRegistration::Create() | 85 ServiceWorkerRegistration::Create() |
| 84 ->set_registration_id( | 86 ->set_registration_id( |
| 85 base::Int64ToString(registration_info.registration_id)) | 87 base::Int64ToString(registration_info.registration_id)) |
| 86 ->set_scope_url(registration_info.pattern.spec())); | 88 ->set_scope_url(registration_info.pattern.spec()) |
| 87 if (registration_info.active_version.version_id != | 89 ->set_is_deleted(registration_info.is_deleted)); |
| 88 kInvalidServiceWorkerVersionId) { | |
| 89 registration->set_active_version( | |
| 90 CreateVersionDictionaryValue(registration_info.active_version)); | |
| 91 } | |
| 92 if (registration_info.waiting_version.version_id != | |
| 93 kInvalidServiceWorkerVersionId) { | |
| 94 registration->set_waiting_version( | |
| 95 CreateVersionDictionaryValue(registration_info.waiting_version)); | |
| 96 } | |
| 97 if (registration_info.installing_version.version_id != | |
| 98 kInvalidServiceWorkerVersionId) { | |
| 99 registration->set_installing_version( | |
| 100 CreateVersionDictionaryValue(registration_info.installing_version)); | |
| 101 } | |
| 102 return registration; | 90 return registration; |
| 103 } | 91 } |
| 104 | 92 |
| 93 bool IsStoppedAndRedundant(const ServiceWorkerVersionInfo& version_info) { | |
| 94 return version_info.running_status == | |
| 95 content::ServiceWorkerVersion::STOPPED && | |
| 96 version_info.status == content::ServiceWorkerVersion::REDUNDANT; | |
| 97 } | |
| 98 | |
| 105 } // namespace | 99 } // namespace |
| 106 | 100 |
| 107 using Response = DevToolsProtocolClient::Response; | 101 using Response = DevToolsProtocolClient::Response; |
| 108 | 102 |
| 109 class ServiceWorkerHandler::ContextObserver | 103 class ServiceWorkerHandler::ContextObserver |
|
pfeldman
2015/03/12 12:23:23
Is this time to kick it out of the class? Seems li
horo
2015/03/12 13:54:14
Done.
| |
| 110 : public ServiceWorkerContextObserver, | 104 : public ServiceWorkerContextObserver, |
| 111 public base::RefCountedThreadSafe<ContextObserver> { | 105 public base::RefCountedThreadSafe<ContextObserver> { |
| 112 public: | 106 public: |
| 113 ContextObserver(scoped_refptr<ServiceWorkerContextWrapper> context, | 107 ContextObserver(scoped_refptr<ServiceWorkerContextWrapper> context, |
| 114 base::WeakPtr<ServiceWorkerHandler> handler); | 108 base::WeakPtr<ServiceWorkerHandler> handler); |
| 115 void Start(); | 109 void Start(); |
| 116 void Stop(); | 110 void Stop(); |
| 117 | 111 |
| 118 private: | 112 private: |
| 119 friend class base::RefCountedThreadSafe<ContextObserver>; | 113 friend class base::RefCountedThreadSafe<ContextObserver>; |
| 120 ~ContextObserver() override; | 114 ~ContextObserver() override; |
| 121 void GetStoredRegistrationsOnIOThread(); | 115 void GetStoredRegistrationsOnIOThread(); |
| 122 void OnStoredRegistrationsOnIOThread( | 116 void OnStoredRegistrationsOnIOThread( |
| 123 const std::vector<ServiceWorkerRegistrationInfo>& registrations); | 117 const std::vector<ServiceWorkerRegistrationInfo>& stored_registrations); |
| 124 void StopOnIOThread(); | 118 void StopOnIOThread(); |
| 125 | 119 |
| 126 void OnVersionUpdated(int64 version_id); | 120 void StoreRegistrationInfo( |
| 127 void OnRegistrationUpdated(int64 registration_id); | 121 const ServiceWorkerRegistrationInfo& registration, |
| 122 base::ScopedPtrHashMap<int64, ServiceWorkerRegistrationInfo>* info_map); | |
| 123 void StoreVersionInfo(const ServiceWorkerVersionInfo& version); | |
| 124 | |
| 125 void SendRegistrationInfo(int64 registration_id, | |
| 126 const GURL& pattern, | |
| 127 bool is_deleted); | |
| 128 void SendVersionInfo(const ServiceWorkerVersionInfo& version); | |
| 128 | 129 |
| 129 // ServiceWorkerContextObserver implements | 130 // ServiceWorkerContextObserver implements |
| 130 void OnRunningStateChanged(int64 version_id) override; | 131 virtual void OnNewLiveRegistration(int64 registration_id, |
| 131 void OnVersionStateChanged(int64 version_id) override; | 132 const GURL& pattern) override; |
| 133 virtual void OnNewLiveVersion(int64 version_id, | |
| 134 int64 registration_id, | |
| 135 const GURL& script_url) override; | |
| 136 void OnRunningStateChanged( | |
| 137 int64 version_id, | |
| 138 content::ServiceWorkerVersion::RunningStatus running_status) override; | |
| 139 void OnVersionStateChanged( | |
| 140 int64 version_id, | |
| 141 content::ServiceWorkerVersion::Status status) override; | |
| 132 void OnRegistrationStored(int64 registration_id, | 142 void OnRegistrationStored(int64 registration_id, |
| 133 const GURL& pattern) override; | 143 const GURL& pattern) override; |
| 134 void OnRegistrationDeleted(int64 registration_id, | 144 void OnRegistrationDeleted(int64 registration_id, |
| 135 const GURL& pattern) override; | 145 const GURL& pattern) override; |
| 136 | 146 |
| 147 base::ScopedPtrHashMap<int64, ServiceWorkerVersionInfo> version_info_map_; | |
| 137 scoped_refptr<ServiceWorkerContextWrapper> context_; | 148 scoped_refptr<ServiceWorkerContextWrapper> context_; |
| 138 base::WeakPtr<ServiceWorkerHandler> handler_; | 149 base::WeakPtr<ServiceWorkerHandler> handler_; |
| 139 }; | 150 }; |
| 140 | 151 |
| 141 ServiceWorkerHandler::ContextObserver::ContextObserver( | 152 ServiceWorkerHandler::ContextObserver::ContextObserver( |
| 142 scoped_refptr<ServiceWorkerContextWrapper> context, | 153 scoped_refptr<ServiceWorkerContextWrapper> context, |
| 143 base::WeakPtr<ServiceWorkerHandler> handler) | 154 base::WeakPtr<ServiceWorkerHandler> handler) |
| 144 : context_(context), handler_(handler) { | 155 : context_(context), handler_(handler) { |
| 145 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 156 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 146 } | 157 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 161 } | 172 } |
| 162 | 173 |
| 163 void ServiceWorkerHandler::ContextObserver::GetStoredRegistrationsOnIOThread() { | 174 void ServiceWorkerHandler::ContextObserver::GetStoredRegistrationsOnIOThread() { |
| 164 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 175 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 165 context_->context()->storage()->GetAllRegistrations(base::Bind( | 176 context_->context()->storage()->GetAllRegistrations(base::Bind( |
| 166 &ServiceWorkerHandler::ContextObserver::OnStoredRegistrationsOnIOThread, | 177 &ServiceWorkerHandler::ContextObserver::OnStoredRegistrationsOnIOThread, |
| 167 this)); | 178 this)); |
| 168 } | 179 } |
| 169 | 180 |
| 170 void ServiceWorkerHandler::ContextObserver::OnStoredRegistrationsOnIOThread( | 181 void ServiceWorkerHandler::ContextObserver::OnStoredRegistrationsOnIOThread( |
| 171 const std::vector<ServiceWorkerRegistrationInfo>& registrations) { | 182 const std::vector<ServiceWorkerRegistrationInfo>& stored_registrations) { |
| 172 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 183 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 173 context_->AddObserver(this); | 184 context_->AddObserver(this); |
| 185 | |
| 186 base::ScopedPtrHashMap<int64, ServiceWorkerRegistrationInfo> | |
| 187 registration_info_map; | |
| 188 for (const auto& registration : stored_registrations) | |
| 189 StoreRegistrationInfo(registration, ®istration_info_map); | |
| 190 for (const auto& registration : | |
| 191 context_->context()->GetAllLiveRegistrationInfo()) { | |
| 192 StoreRegistrationInfo(registration, ®istration_info_map); | |
| 193 } | |
| 194 for (const auto& version : context_->context()->GetAllLiveVersionInfo()) | |
| 195 StoreVersionInfo(version); | |
| 196 | |
| 197 std::vector<ServiceWorkerRegistrationInfo> registrations; | |
| 198 registrations.reserve(registration_info_map.size()); | |
| 199 for (const auto& registration_id_info_pair : registration_info_map) | |
| 200 registrations.push_back(*registration_id_info_pair.second); | |
| 201 | |
| 202 std::vector<ServiceWorkerVersionInfo> versions; | |
| 203 versions.reserve(version_info_map_.size()); | |
| 204 | |
| 205 for (auto version_it = version_info_map_.begin(); | |
| 206 version_it != version_info_map_.end();) { | |
| 207 versions.push_back(*version_it->second); | |
| 208 if (IsStoppedAndRedundant(*version_it->second)) | |
| 209 version_info_map_.erase(version_it++); | |
| 210 else | |
| 211 ++version_it; | |
| 212 } | |
| 213 | |
| 174 BrowserThread::PostTask( | 214 BrowserThread::PostTask( |
| 175 BrowserThread::UI, FROM_HERE, | 215 BrowserThread::UI, FROM_HERE, |
| 176 base::Bind(&ServiceWorkerHandler::OnWorkerRegistrationUpdated, handler_, | 216 base::Bind(&ServiceWorkerHandler::OnWorkerRegistrationUpdated, handler_, |
| 177 registrations)); | 217 registrations)); |
| 178 BrowserThread::PostTask( | 218 BrowserThread::PostTask( |
| 179 BrowserThread::UI, FROM_HERE, | 219 BrowserThread::UI, FROM_HERE, |
| 180 base::Bind(&ServiceWorkerHandler::OnWorkerRegistrationUpdated, handler_, | |
| 181 context_->context()->GetAllLiveRegistrationInfo())); | |
| 182 BrowserThread::PostTask( | |
| 183 BrowserThread::UI, FROM_HERE, | |
| 184 base::Bind(&ServiceWorkerHandler::OnWorkerVersionUpdated, handler_, | 220 base::Bind(&ServiceWorkerHandler::OnWorkerVersionUpdated, handler_, |
| 185 context_->context()->GetAllLiveVersionInfo())); | 221 versions)); |
| 186 } | 222 } |
| 187 | 223 |
| 188 void ServiceWorkerHandler::ContextObserver::StopOnIOThread() { | 224 void ServiceWorkerHandler::ContextObserver::StopOnIOThread() { |
| 189 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 225 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 190 context_->RemoveObserver(this); | 226 context_->RemoveObserver(this); |
| 191 } | 227 } |
| 192 | 228 |
| 193 ServiceWorkerHandler::ContextObserver::~ContextObserver() { | 229 ServiceWorkerHandler::ContextObserver::~ContextObserver() { |
| 194 } | 230 } |
| 195 | 231 |
| 196 void ServiceWorkerHandler::ContextObserver::OnVersionUpdated(int64 version_id) { | 232 void ServiceWorkerHandler::ContextObserver::StoreRegistrationInfo( |
| 233 const ServiceWorkerRegistrationInfo& registration_info, | |
| 234 base::ScopedPtrHashMap<int64, ServiceWorkerRegistrationInfo>* info_map) { | |
| 197 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 198 content::ServiceWorkerVersion* version = | 236 if (registration_info.registration_id == kInvalidServiceWorkerRegistrationId) |
| 199 context_->context()->GetLiveVersion(version_id); | |
| 200 if (!version) | |
| 201 return; | 237 return; |
| 202 OnRegistrationUpdated(version->registration_id()); | 238 info_map->set(registration_info.registration_id, |
| 239 scoped_ptr<ServiceWorkerRegistrationInfo>( | |
| 240 new ServiceWorkerRegistrationInfo(registration_info))); | |
| 241 StoreVersionInfo(registration_info.active_version); | |
| 242 StoreVersionInfo(registration_info.waiting_version); | |
| 243 StoreVersionInfo(registration_info.installing_version); | |
| 244 } | |
| 245 | |
| 246 void ServiceWorkerHandler::ContextObserver::StoreVersionInfo( | |
| 247 const ServiceWorkerVersionInfo& version_info) { | |
| 248 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 249 if (version_info.version_id == kInvalidServiceWorkerVersionId) | |
| 250 return; | |
| 251 version_info_map_.set(version_info.version_id, | |
| 252 scoped_ptr<ServiceWorkerVersionInfo>( | |
| 253 new ServiceWorkerVersionInfo(version_info))); | |
| 254 } | |
| 255 | |
| 256 void ServiceWorkerHandler::ContextObserver::SendRegistrationInfo( | |
| 257 int64 registration_id, | |
| 258 const GURL& pattern, | |
| 259 bool is_deleted) { | |
| 260 std::vector<ServiceWorkerRegistrationInfo> registrations; | |
| 261 registrations.push_back( | |
| 262 ServiceWorkerRegistrationInfo(pattern, registration_id, is_deleted)); | |
| 263 BrowserThread::PostTask( | |
| 264 BrowserThread::UI, FROM_HERE, | |
| 265 base::Bind(&ServiceWorkerHandler::OnWorkerRegistrationUpdated, handler_, | |
| 266 registrations)); | |
| 267 } | |
| 268 | |
| 269 void ServiceWorkerHandler::ContextObserver::SendVersionInfo( | |
| 270 const ServiceWorkerVersionInfo& version_info) { | |
| 271 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 203 std::vector<ServiceWorkerVersionInfo> versions; | 272 std::vector<ServiceWorkerVersionInfo> versions; |
| 204 versions.push_back(version->GetInfo()); | 273 versions.push_back(version_info); |
| 205 BrowserThread::PostTask( | 274 BrowserThread::PostTask( |
| 206 BrowserThread::UI, FROM_HERE, | 275 BrowserThread::UI, FROM_HERE, |
| 207 base::Bind(&ServiceWorkerHandler::OnWorkerVersionUpdated, handler_, | 276 base::Bind(&ServiceWorkerHandler::OnWorkerVersionUpdated, handler_, |
| 208 versions)); | 277 versions)); |
| 209 } | 278 } |
| 210 | 279 |
| 211 void ServiceWorkerHandler::ContextObserver::OnRegistrationUpdated( | 280 void ServiceWorkerHandler::ContextObserver::OnNewLiveRegistration( |
| 212 int64 registration_id) { | 281 int64 registration_id, |
| 213 content::ServiceWorkerRegistration* registration = | 282 const GURL& pattern) { |
| 214 context_->context()->GetLiveRegistration(registration_id); | 283 SendRegistrationInfo(registration_id, pattern, false); |
| 215 if (!registration) | 284 } |
| 285 | |
| 286 void ServiceWorkerHandler::ContextObserver::OnNewLiveVersion( | |
| 287 int64 version_id, | |
| 288 int64 registration_id, | |
| 289 const GURL& script_url) { | |
| 290 if (ServiceWorkerVersionInfo* version = version_info_map_.get(version_id)) { | |
| 291 DCHECK(version->registration_id == registration_id); | |
| 292 DCHECK(version->script_url == script_url); | |
| 216 return; | 293 return; |
| 217 std::vector<ServiceWorkerRegistrationInfo> registrations; | 294 } |
| 218 registrations.push_back(registration->GetInfo()); | 295 |
| 219 BrowserThread::PostTask( | 296 scoped_ptr<ServiceWorkerVersionInfo> version(new ServiceWorkerVersionInfo()); |
| 220 BrowserThread::UI, FROM_HERE, | 297 version->version_id = version_id; |
| 221 base::Bind(&ServiceWorkerHandler::OnWorkerRegistrationUpdated, handler_, | 298 version->registration_id = registration_id; |
| 222 registrations)); | 299 version->script_url = script_url; |
| 300 SendVersionInfo(*version); | |
| 301 if (!IsStoppedAndRedundant(*version)) | |
| 302 version_info_map_.set(version_id, version.Pass()); | |
| 223 } | 303 } |
| 224 | 304 |
| 225 void ServiceWorkerHandler::ContextObserver::OnRunningStateChanged( | 305 void ServiceWorkerHandler::ContextObserver::OnRunningStateChanged( |
| 226 int64 version_id) { | 306 int64 version_id, |
| 227 OnVersionUpdated(version_id); | 307 content::ServiceWorkerVersion::RunningStatus running_status) { |
| 308 ServiceWorkerVersionInfo* version = version_info_map_.get(version_id); | |
| 309 DCHECK(version); | |
| 310 if (version->running_status == running_status) | |
| 311 return; | |
| 312 version->running_status = running_status; | |
| 313 SendVersionInfo(*version); | |
| 314 if (IsStoppedAndRedundant(*version)) | |
| 315 version_info_map_.erase(version_id); | |
| 228 } | 316 } |
| 229 | 317 |
| 230 void ServiceWorkerHandler::ContextObserver::OnVersionStateChanged( | 318 void ServiceWorkerHandler::ContextObserver::OnVersionStateChanged( |
| 231 int64 version_id) { | 319 int64 version_id, |
| 232 OnVersionUpdated(version_id); | 320 content::ServiceWorkerVersion::Status status) { |
| 321 ServiceWorkerVersionInfo* version = version_info_map_.get(version_id); | |
| 322 DCHECK(version); | |
| 323 if (version->status == status) | |
| 324 return; | |
| 325 version->status = status; | |
| 326 SendVersionInfo(*version); | |
| 327 if (IsStoppedAndRedundant(*version)) | |
| 328 version_info_map_.erase(version_id); | |
| 233 } | 329 } |
| 234 | 330 |
| 235 void ServiceWorkerHandler::ContextObserver::OnRegistrationStored( | 331 void ServiceWorkerHandler::ContextObserver::OnRegistrationStored( |
| 236 int64 registration_id, | 332 int64 registration_id, |
| 237 const GURL& pattern) { | 333 const GURL& pattern) { |
| 238 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 334 SendRegistrationInfo(registration_id, pattern, false); |
| 239 content::ServiceWorkerRegistration* registration = | |
| 240 context_->context()->GetLiveRegistration(registration_id); | |
| 241 DCHECK(registration); | |
| 242 std::vector<ServiceWorkerRegistrationInfo> registrations; | |
| 243 registrations.push_back(registration->GetInfo()); | |
| 244 BrowserThread::PostTask( | |
| 245 BrowserThread::UI, FROM_HERE, | |
| 246 base::Bind(&ServiceWorkerHandler::OnWorkerRegistrationUpdated, handler_, | |
| 247 registrations)); | |
| 248 } | 335 } |
| 249 | 336 |
| 250 void ServiceWorkerHandler::ContextObserver::OnRegistrationDeleted( | 337 void ServiceWorkerHandler::ContextObserver::OnRegistrationDeleted( |
| 251 int64 registration_id, | 338 int64 registration_id, |
| 252 const GURL& pattern) { | 339 const GURL& pattern) { |
| 253 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 340 SendRegistrationInfo(registration_id, pattern, true); |
| 254 BrowserThread::PostTask( | |
| 255 BrowserThread::UI, FROM_HERE, | |
| 256 base::Bind(&ServiceWorkerHandler::OnWorkerRegistrationDeleted, handler_, | |
| 257 registration_id)); | |
| 258 } | 341 } |
| 259 | 342 |
| 260 ServiceWorkerHandler::ServiceWorkerHandler() | 343 ServiceWorkerHandler::ServiceWorkerHandler() |
| 261 : enabled_(false), weak_factory_(this) { | 344 : enabled_(false), weak_factory_(this) { |
| 262 } | 345 } |
| 263 | 346 |
| 264 ServiceWorkerHandler::~ServiceWorkerHandler() { | 347 ServiceWorkerHandler::~ServiceWorkerHandler() { |
| 265 Disable(); | 348 Disable(); |
| 266 } | 349 } |
| 267 | 350 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 void ServiceWorkerHandler::OnWorkerVersionUpdated( | 462 void ServiceWorkerHandler::OnWorkerVersionUpdated( |
| 380 const std::vector<ServiceWorkerVersionInfo>& versions) { | 463 const std::vector<ServiceWorkerVersionInfo>& versions) { |
| 381 std::vector<scoped_refptr<ServiceWorkerVersion>> version_values; | 464 std::vector<scoped_refptr<ServiceWorkerVersion>> version_values; |
| 382 for (const auto& version : versions) { | 465 for (const auto& version : versions) { |
| 383 version_values.push_back(CreateVersionDictionaryValue(version)); | 466 version_values.push_back(CreateVersionDictionaryValue(version)); |
| 384 } | 467 } |
| 385 client_->WorkerVersionUpdated( | 468 client_->WorkerVersionUpdated( |
| 386 WorkerVersionUpdatedParams::Create()->set_versions(version_values)); | 469 WorkerVersionUpdatedParams::Create()->set_versions(version_values)); |
| 387 } | 470 } |
| 388 | 471 |
| 389 void ServiceWorkerHandler::OnWorkerRegistrationDeleted(int64 registration_id) { | |
| 390 client_->WorkerRegistrationDeleted( | |
| 391 WorkerRegistrationDeletedParams::Create()->set_registration_id( | |
| 392 base::Int64ToString(registration_id))); | |
| 393 } | |
| 394 | |
| 395 void ServiceWorkerHandler::DispatchProtocolMessage( | 472 void ServiceWorkerHandler::DispatchProtocolMessage( |
| 396 DevToolsAgentHost* host, | 473 DevToolsAgentHost* host, |
| 397 const std::string& message) { | 474 const std::string& message) { |
| 398 | 475 |
| 399 auto it = attached_hosts_.find(host->GetId()); | 476 auto it = attached_hosts_.find(host->GetId()); |
| 400 if (it == attached_hosts_.end()) | 477 if (it == attached_hosts_.end()) |
| 401 return; // Already disconnected. | 478 return; // Already disconnected. |
| 402 | 479 |
| 403 client_->DispatchMessage( | 480 client_->DispatchMessage( |
| 404 DispatchMessageParams::Create()-> | 481 DispatchMessageParams::Create()-> |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 445 bool ServiceWorkerHandler::MatchesInspectedPage( | 522 bool ServiceWorkerHandler::MatchesInspectedPage( |
| 446 ServiceWorkerDevToolsAgentHost* host) { | 523 ServiceWorkerDevToolsAgentHost* host) { |
| 447 // TODO(pfeldman): match based on scope. | 524 // TODO(pfeldman): match based on scope. |
| 448 // TODO(pfeldman): match iframes. | 525 // TODO(pfeldman): match iframes. |
| 449 return host->GetURL().host() == url_.host(); | 526 return host->GetURL().host() == url_.host(); |
| 450 } | 527 } |
| 451 | 528 |
| 452 } // namespace service_worker | 529 } // namespace service_worker |
| 453 } // namespace devtools | 530 } // namespace devtools |
| 454 } // namespace content | 531 } // namespace content |
| OLD | NEW |