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 <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 } | 819 } |
820 | 820 |
821 background_sync_dispatcher_->Sync( | 821 background_sync_dispatcher_->Sync( |
822 registration.Pass(), base::Bind(&self::OnSyncEventFinished, | 822 registration.Pass(), base::Bind(&self::OnSyncEventFinished, |
823 weak_factory_.GetWeakPtr(), request_id)); | 823 weak_factory_.GetWeakPtr(), request_id)); |
824 } | 824 } |
825 | 825 |
826 void ServiceWorkerVersion::DispatchNotificationClickEvent( | 826 void ServiceWorkerVersion::DispatchNotificationClickEvent( |
827 const StatusCallback& callback, | 827 const StatusCallback& callback, |
828 int64_t persistent_notification_id, | 828 int64_t persistent_notification_id, |
829 const PlatformNotificationData& notification_data) { | 829 const PlatformNotificationData& notification_data, |
| 830 int action_index) { |
830 DCHECK_EQ(ACTIVATED, status()) << status(); | 831 DCHECK_EQ(ACTIVATED, status()) << status(); |
831 if (running_status() != RUNNING) { | 832 if (running_status() != RUNNING) { |
832 // Schedule calling this method after starting the worker. | 833 // Schedule calling this method after starting the worker. |
833 StartWorker(base::Bind( | 834 StartWorker(base::Bind( |
834 &RunTaskAfterStartWorker, weak_factory_.GetWeakPtr(), callback, | 835 &RunTaskAfterStartWorker, weak_factory_.GetWeakPtr(), callback, |
835 base::Bind(&self::DispatchNotificationClickEvent, | 836 base::Bind(&self::DispatchNotificationClickEvent, |
836 weak_factory_.GetWeakPtr(), callback, | 837 weak_factory_.GetWeakPtr(), callback, |
837 persistent_notification_id, notification_data))); | 838 persistent_notification_id, notification_data, |
| 839 action_index))); |
838 return; | 840 return; |
839 } | 841 } |
840 | 842 |
841 int request_id = AddRequest(callback, ¬ification_click_requests_, | 843 int request_id = AddRequest(callback, ¬ification_click_requests_, |
842 REQUEST_NOTIFICATION_CLICK); | 844 REQUEST_NOTIFICATION_CLICK); |
843 ServiceWorkerStatusCode status = | 845 ServiceWorkerStatusCode status = |
844 embedded_worker_->SendMessage(ServiceWorkerMsg_NotificationClickEvent( | 846 embedded_worker_->SendMessage(ServiceWorkerMsg_NotificationClickEvent( |
845 request_id, persistent_notification_id, notification_data)); | 847 request_id, persistent_notification_id, notification_data, |
| 848 action_index)); |
846 if (status != SERVICE_WORKER_OK) { | 849 if (status != SERVICE_WORKER_OK) { |
847 notification_click_requests_.Remove(request_id); | 850 notification_click_requests_.Remove(request_id); |
848 RunSoon(base::Bind(callback, status)); | 851 RunSoon(base::Bind(callback, status)); |
849 } | 852 } |
850 } | 853 } |
851 | 854 |
852 void ServiceWorkerVersion::DispatchPushEvent(const StatusCallback& callback, | 855 void ServiceWorkerVersion::DispatchPushEvent(const StatusCallback& callback, |
853 const std::string& data) { | 856 const std::string& data) { |
854 DCHECK_EQ(ACTIVATED, status()) << status(); | 857 DCHECK_EQ(ACTIVATED, status()) << status(); |
855 if (running_status() != RUNNING) { | 858 if (running_status() != RUNNING) { |
(...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2295 base::string16()); | 2298 base::string16()); |
2296 service_port_dispatcher_.reset(); | 2299 service_port_dispatcher_.reset(); |
2297 } | 2300 } |
2298 | 2301 |
2299 void ServiceWorkerVersion::OnBackgroundSyncDispatcherConnectionError() { | 2302 void ServiceWorkerVersion::OnBackgroundSyncDispatcherConnectionError() { |
2300 RunIDMapCallbacks(&sync_requests_, SERVICE_WORKER_ERROR_FAILED); | 2303 RunIDMapCallbacks(&sync_requests_, SERVICE_WORKER_ERROR_FAILED); |
2301 background_sync_dispatcher_.reset(); | 2304 background_sync_dispatcher_.reset(); |
2302 } | 2305 } |
2303 | 2306 |
2304 } // namespace content | 2307 } // namespace content |
OLD | NEW |