| 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_context_core.h" | 5 #include "content/browser/service_worker/service_worker_context_core.h" |
| 6 | 6 |
| 7 #include "base/barrier_closure.h" | 7 #include "base/barrier_closure.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 ServiceWorkerRegistration* registration) { | 296 ServiceWorkerRegistration* registration) { |
| 297 if (status != SERVICE_WORKER_OK) { | 297 if (status != SERVICE_WORKER_OK) { |
| 298 DCHECK(!registration); | 298 DCHECK(!registration); |
| 299 callback.Run(status, status_message, kInvalidServiceWorkerRegistrationId); | 299 callback.Run(status, status_message, kInvalidServiceWorkerRegistrationId); |
| 300 return; | 300 return; |
| 301 } | 301 } |
| 302 | 302 |
| 303 DCHECK(registration); | 303 DCHECK(registration); |
| 304 callback.Run(status, status_message, registration->id()); | 304 callback.Run(status, status_message, registration->id()); |
| 305 if (observer_list_.get()) { | 305 if (observer_list_.get()) { |
| 306 observer_list_->Notify(&ServiceWorkerContextObserver::OnRegistrationStored, | 306 observer_list_->Notify(FROM_HERE, |
| 307 &ServiceWorkerContextObserver::OnRegistrationStored, |
| 307 pattern); | 308 pattern); |
| 308 } | 309 } |
| 309 } | 310 } |
| 310 | 311 |
| 311 void ServiceWorkerContextCore::UnregistrationComplete( | 312 void ServiceWorkerContextCore::UnregistrationComplete( |
| 312 const GURL& pattern, | 313 const GURL& pattern, |
| 313 const ServiceWorkerContextCore::UnregistrationCallback& callback, | 314 const ServiceWorkerContextCore::UnregistrationCallback& callback, |
| 314 int64 registration_id, | 315 int64 registration_id, |
| 315 ServiceWorkerStatusCode status) { | 316 ServiceWorkerStatusCode status) { |
| 316 callback.Run(status); | 317 callback.Run(status); |
| 317 if (observer_list_.get()) { | 318 if (observer_list_.get()) { |
| 318 observer_list_->Notify(&ServiceWorkerContextObserver::OnRegistrationDeleted, | 319 observer_list_->Notify(FROM_HERE, |
| 320 &ServiceWorkerContextObserver::OnRegistrationDeleted, |
| 319 registration_id, pattern); | 321 registration_id, pattern); |
| 320 } | 322 } |
| 321 } | 323 } |
| 322 | 324 |
| 323 ServiceWorkerRegistration* ServiceWorkerContextCore::GetLiveRegistration( | 325 ServiceWorkerRegistration* ServiceWorkerContextCore::GetLiveRegistration( |
| 324 int64 id) { | 326 int64 id) { |
| 325 RegistrationsMap::iterator it = live_registrations_.find(id); | 327 RegistrationsMap::iterator it = live_registrations_.find(id); |
| 326 return (it != live_registrations_.end()) ? it->second : NULL; | 328 return (it != live_registrations_.end()) ? it->second : NULL; |
| 327 } | 329 } |
| 328 | 330 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 temp->frame_id(), | 434 temp->frame_id(), |
| 433 new_provider_id, | 435 new_provider_id, |
| 434 temp->dispatcher_host()); | 436 temp->dispatcher_host()); |
| 435 map->Replace(new_provider_id, transferee.release()); | 437 map->Replace(new_provider_id, transferee.release()); |
| 436 delete temp; | 438 delete temp; |
| 437 } | 439 } |
| 438 | 440 |
| 439 void ServiceWorkerContextCore::OnWorkerStarted(ServiceWorkerVersion* version) { | 441 void ServiceWorkerContextCore::OnWorkerStarted(ServiceWorkerVersion* version) { |
| 440 if (!observer_list_.get()) | 442 if (!observer_list_.get()) |
| 441 return; | 443 return; |
| 442 observer_list_->Notify(&ServiceWorkerContextObserver::OnWorkerStarted, | 444 observer_list_->Notify( |
| 443 version->version_id(), | 445 FROM_HERE, &ServiceWorkerContextObserver::OnWorkerStarted, |
| 444 version->embedded_worker()->process_id(), | 446 version->version_id(), version->embedded_worker()->process_id(), |
| 445 version->embedded_worker()->thread_id()); | 447 version->embedded_worker()->thread_id()); |
| 446 } | 448 } |
| 447 | 449 |
| 448 void ServiceWorkerContextCore::OnWorkerStopped(ServiceWorkerVersion* version) { | 450 void ServiceWorkerContextCore::OnWorkerStopped(ServiceWorkerVersion* version) { |
| 449 if (!observer_list_.get()) | 451 if (!observer_list_.get()) |
| 450 return; | 452 return; |
| 451 observer_list_->Notify(&ServiceWorkerContextObserver::OnWorkerStopped, | 453 observer_list_->Notify( |
| 452 version->version_id(), | 454 FROM_HERE, &ServiceWorkerContextObserver::OnWorkerStopped, |
| 453 version->embedded_worker()->process_id(), | 455 version->version_id(), version->embedded_worker()->process_id(), |
| 454 version->embedded_worker()->thread_id()); | 456 version->embedded_worker()->thread_id()); |
| 455 } | 457 } |
| 456 | 458 |
| 457 void ServiceWorkerContextCore::OnVersionStateChanged( | 459 void ServiceWorkerContextCore::OnVersionStateChanged( |
| 458 ServiceWorkerVersion* version) { | 460 ServiceWorkerVersion* version) { |
| 459 if (!observer_list_.get()) | 461 if (!observer_list_.get()) |
| 460 return; | 462 return; |
| 461 observer_list_->Notify(&ServiceWorkerContextObserver::OnVersionStateChanged, | 463 observer_list_->Notify(FROM_HERE, |
| 464 &ServiceWorkerContextObserver::OnVersionStateChanged, |
| 462 version->version_id()); | 465 version->version_id()); |
| 463 } | 466 } |
| 464 | 467 |
| 465 void ServiceWorkerContextCore::OnErrorReported( | 468 void ServiceWorkerContextCore::OnErrorReported( |
| 466 ServiceWorkerVersion* version, | 469 ServiceWorkerVersion* version, |
| 467 const base::string16& error_message, | 470 const base::string16& error_message, |
| 468 int line_number, | 471 int line_number, |
| 469 int column_number, | 472 int column_number, |
| 470 const GURL& source_url) { | 473 const GURL& source_url) { |
| 471 if (!observer_list_.get()) | 474 if (!observer_list_.get()) |
| 472 return; | 475 return; |
| 473 observer_list_->Notify( | 476 observer_list_->Notify( |
| 474 &ServiceWorkerContextObserver::OnErrorReported, | 477 FROM_HERE, &ServiceWorkerContextObserver::OnErrorReported, |
| 475 version->version_id(), | 478 version->version_id(), version->embedded_worker()->process_id(), |
| 476 version->embedded_worker()->process_id(), | |
| 477 version->embedded_worker()->thread_id(), | 479 version->embedded_worker()->thread_id(), |
| 478 ServiceWorkerContextObserver::ErrorInfo( | 480 ServiceWorkerContextObserver::ErrorInfo(error_message, line_number, |
| 479 error_message, line_number, column_number, source_url)); | 481 column_number, source_url)); |
| 480 } | 482 } |
| 481 | 483 |
| 482 void ServiceWorkerContextCore::OnReportConsoleMessage( | 484 void ServiceWorkerContextCore::OnReportConsoleMessage( |
| 483 ServiceWorkerVersion* version, | 485 ServiceWorkerVersion* version, |
| 484 int source_identifier, | 486 int source_identifier, |
| 485 int message_level, | 487 int message_level, |
| 486 const base::string16& message, | 488 const base::string16& message, |
| 487 int line_number, | 489 int line_number, |
| 488 const GURL& source_url) { | 490 const GURL& source_url) { |
| 489 if (!observer_list_.get()) | 491 if (!observer_list_.get()) |
| 490 return; | 492 return; |
| 491 observer_list_->Notify( | 493 observer_list_->Notify( |
| 492 &ServiceWorkerContextObserver::OnReportConsoleMessage, | 494 FROM_HERE, &ServiceWorkerContextObserver::OnReportConsoleMessage, |
| 493 version->version_id(), | 495 version->version_id(), version->embedded_worker()->process_id(), |
| 494 version->embedded_worker()->process_id(), | |
| 495 version->embedded_worker()->thread_id(), | 496 version->embedded_worker()->thread_id(), |
| 496 ServiceWorkerContextObserver::ConsoleMessage( | 497 ServiceWorkerContextObserver::ConsoleMessage( |
| 497 source_identifier, message_level, message, line_number, source_url)); | 498 source_identifier, message_level, message, line_number, source_url)); |
| 498 } | 499 } |
| 499 | 500 |
| 500 ServiceWorkerProcessManager* ServiceWorkerContextCore::process_manager() { | 501 ServiceWorkerProcessManager* ServiceWorkerContextCore::process_manager() { |
| 501 return wrapper_->process_manager(); | 502 return wrapper_->process_manager(); |
| 502 } | 503 } |
| 503 | 504 |
| 504 } // namespace content | 505 } // namespace content |
| OLD | NEW |