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/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "content/browser/message_port_message_filter.h" | 10 #include "content/browser/message_port_message_filter.h" |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 ServiceWorkerStatusCode status = embedded_worker_->SendMessage( | 389 ServiceWorkerStatusCode status = embedded_worker_->SendMessage( |
390 ServiceWorkerMsg_SyncEvent(request_id)); | 390 ServiceWorkerMsg_SyncEvent(request_id)); |
391 if (status != SERVICE_WORKER_OK) { | 391 if (status != SERVICE_WORKER_OK) { |
392 sync_callbacks_.Remove(request_id); | 392 sync_callbacks_.Remove(request_id); |
393 RunSoon(base::Bind(callback, status)); | 393 RunSoon(base::Bind(callback, status)); |
394 } | 394 } |
395 } | 395 } |
396 | 396 |
397 void ServiceWorkerVersion::DispatchNotificationClickEvent( | 397 void ServiceWorkerVersion::DispatchNotificationClickEvent( |
398 const StatusCallback& callback, | 398 const StatusCallback& callback, |
399 const std::string& notification_id) { | 399 const std::string& notification_id, |
| 400 const ShowDesktopNotificationHostMsgParams& notification_data) { |
400 DCHECK_EQ(ACTIVATED, status()) << status(); | 401 DCHECK_EQ(ACTIVATED, status()) << status(); |
401 | 402 |
402 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 403 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
403 switches::kEnableExperimentalWebPlatformFeatures)) { | 404 switches::kEnableExperimentalWebPlatformFeatures)) { |
404 callback.Run(SERVICE_WORKER_ERROR_ABORT); | 405 callback.Run(SERVICE_WORKER_ERROR_ABORT); |
405 return; | 406 return; |
406 } | 407 } |
407 | 408 |
408 if (running_status() != RUNNING) { | 409 if (running_status() != RUNNING) { |
409 // Schedule calling this method after starting the worker. | 410 // Schedule calling this method after starting the worker. |
410 StartWorker(base::Bind(&RunTaskAfterStartWorker, | 411 StartWorker(base::Bind(&RunTaskAfterStartWorker, |
411 weak_factory_.GetWeakPtr(), callback, | 412 weak_factory_.GetWeakPtr(), callback, |
412 base::Bind(&self::DispatchNotificationClickEvent, | 413 base::Bind(&self::DispatchNotificationClickEvent, |
413 weak_factory_.GetWeakPtr(), | 414 weak_factory_.GetWeakPtr(), |
414 callback, notification_id))); | 415 callback, notification_id, |
| 416 notification_data))); |
415 return; | 417 return; |
416 } | 418 } |
417 | 419 |
418 int request_id = | 420 int request_id = |
419 notification_click_callbacks_.Add(new StatusCallback(callback)); | 421 notification_click_callbacks_.Add(new StatusCallback(callback)); |
420 ServiceWorkerStatusCode status = embedded_worker_->SendMessage( | 422 ServiceWorkerStatusCode status = embedded_worker_->SendMessage( |
421 ServiceWorkerMsg_NotificationClickEvent(request_id, notification_id)); | 423 ServiceWorkerMsg_NotificationClickEvent(request_id, |
| 424 notification_id, |
| 425 notification_data)); |
422 if (status != SERVICE_WORKER_OK) { | 426 if (status != SERVICE_WORKER_OK) { |
423 notification_click_callbacks_.Remove(request_id); | 427 notification_click_callbacks_.Remove(request_id); |
424 RunSoon(base::Bind(callback, status)); | 428 RunSoon(base::Bind(callback, status)); |
425 } | 429 } |
426 } | 430 } |
427 | 431 |
428 void ServiceWorkerVersion::DispatchPushEvent(const StatusCallback& callback, | 432 void ServiceWorkerVersion::DispatchPushEvent(const StatusCallback& callback, |
429 const std::string& data) { | 433 const std::string& data) { |
430 DCHECK_EQ(ACTIVATED, status()) << status(); | 434 DCHECK_EQ(ACTIVATED, status()) << status(); |
431 | 435 |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 SetStatus(REDUNDANT); | 898 SetStatus(REDUNDANT); |
895 StopWorker(base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 899 StopWorker(base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
896 if (!context_) | 900 if (!context_) |
897 return; | 901 return; |
898 std::vector<ServiceWorkerDatabase::ResourceRecord> resources; | 902 std::vector<ServiceWorkerDatabase::ResourceRecord> resources; |
899 script_cache_map_.GetResources(&resources); | 903 script_cache_map_.GetResources(&resources); |
900 context_->storage()->PurgeResources(resources); | 904 context_->storage()->PurgeResources(resources); |
901 } | 905 } |
902 | 906 |
903 } // namespace content | 907 } // namespace content |
OLD | NEW |