| 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_version.h" | 5 #include "content/browser/service_worker/service_worker_version.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 ServiceWorkerStatusCode status = embedded_worker_->SendMessage( | 636 ServiceWorkerStatusCode status = embedded_worker_->SendMessage( |
| 637 ServiceWorkerMsg_SyncEvent(request_id)); | 637 ServiceWorkerMsg_SyncEvent(request_id)); |
| 638 if (status != SERVICE_WORKER_OK) { | 638 if (status != SERVICE_WORKER_OK) { |
| 639 sync_callbacks_.Remove(request_id); | 639 sync_callbacks_.Remove(request_id); |
| 640 RunSoon(base::Bind(callback, status)); | 640 RunSoon(base::Bind(callback, status)); |
| 641 } | 641 } |
| 642 } | 642 } |
| 643 | 643 |
| 644 void ServiceWorkerVersion::DispatchNotificationClickEvent( | 644 void ServiceWorkerVersion::DispatchNotificationClickEvent( |
| 645 const StatusCallback& callback, | 645 const StatusCallback& callback, |
| 646 const std::string& notification_id, | 646 int64_t persistent_notification_id, |
| 647 const PlatformNotificationData& notification_data) { | 647 const PlatformNotificationData& notification_data) { |
| 648 DCHECK_EQ(ACTIVATED, status()) << status(); | 648 DCHECK_EQ(ACTIVATED, status()) << status(); |
| 649 if (running_status() != RUNNING) { | 649 if (running_status() != RUNNING) { |
| 650 // Schedule calling this method after starting the worker. | 650 // Schedule calling this method after starting the worker. |
| 651 StartWorker(base::Bind(&RunTaskAfterStartWorker, | 651 StartWorker(base::Bind( |
| 652 weak_factory_.GetWeakPtr(), callback, | 652 &RunTaskAfterStartWorker, weak_factory_.GetWeakPtr(), callback, |
| 653 base::Bind(&self::DispatchNotificationClickEvent, | 653 base::Bind(&self::DispatchNotificationClickEvent, |
| 654 weak_factory_.GetWeakPtr(), | 654 weak_factory_.GetWeakPtr(), callback, |
| 655 callback, notification_id, | 655 persistent_notification_id, notification_data))); |
| 656 notification_data))); | |
| 657 return; | 656 return; |
| 658 } | 657 } |
| 659 | 658 |
| 660 int request_id = AddRequest(callback, ¬ification_click_callbacks_, | 659 int request_id = AddRequest(callback, ¬ification_click_callbacks_, |
| 661 REQUEST_NOTIFICATION_CLICK); | 660 REQUEST_NOTIFICATION_CLICK); |
| 662 ServiceWorkerStatusCode status = embedded_worker_->SendMessage( | 661 ServiceWorkerStatusCode status = |
| 663 ServiceWorkerMsg_NotificationClickEvent(request_id, | 662 embedded_worker_->SendMessage(ServiceWorkerMsg_NotificationClickEvent( |
| 664 notification_id, | 663 request_id, persistent_notification_id, notification_data)); |
| 665 notification_data)); | |
| 666 if (status != SERVICE_WORKER_OK) { | 664 if (status != SERVICE_WORKER_OK) { |
| 667 notification_click_callbacks_.Remove(request_id); | 665 notification_click_callbacks_.Remove(request_id); |
| 668 RunSoon(base::Bind(callback, status)); | 666 RunSoon(base::Bind(callback, status)); |
| 669 } | 667 } |
| 670 } | 668 } |
| 671 | 669 |
| 672 void ServiceWorkerVersion::DispatchPushEvent(const StatusCallback& callback, | 670 void ServiceWorkerVersion::DispatchPushEvent(const StatusCallback& callback, |
| 673 const std::string& data) { | 671 const std::string& data) { |
| 674 DCHECK_EQ(ACTIVATED, status()) << status(); | 672 DCHECK_EQ(ACTIVATED, status()) << status(); |
| 675 if (running_status() != RUNNING) { | 673 if (running_status() != RUNNING) { |
| (...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1881 return SERVICE_WORKER_ERROR_ABORT; | 1879 return SERVICE_WORKER_ERROR_ABORT; |
| 1882 default: | 1880 default: |
| 1883 return SERVICE_WORKER_ERROR_NETWORK; | 1881 return SERVICE_WORKER_ERROR_NETWORK; |
| 1884 } | 1882 } |
| 1885 } | 1883 } |
| 1886 | 1884 |
| 1887 return default_code; | 1885 return default_code; |
| 1888 } | 1886 } |
| 1889 | 1887 |
| 1890 } // namespace content | 1888 } // namespace content |
| OLD | NEW |