Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: content/browser/service_worker/service_worker_version.cc

Issue 1636483002: Update the PushEvent to have a nullable PushMessageData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 22 matching lines...) Expand all
33 #include "content/browser/service_worker/service_worker_metrics.h" 33 #include "content/browser/service_worker/service_worker_metrics.h"
34 #include "content/browser/service_worker/service_worker_registration.h" 34 #include "content/browser/service_worker/service_worker_registration.h"
35 #include "content/common/service_worker/service_worker_messages.h" 35 #include "content/common/service_worker/service_worker_messages.h"
36 #include "content/common/service_worker/service_worker_type_converters.h" 36 #include "content/common/service_worker/service_worker_type_converters.h"
37 #include "content/common/service_worker/service_worker_utils.h" 37 #include "content/common/service_worker/service_worker_utils.h"
38 #include "content/public/browser/browser_thread.h" 38 #include "content/public/browser/browser_thread.h"
39 #include "content/public/browser/content_browser_client.h" 39 #include "content/public/browser/content_browser_client.h"
40 #include "content/public/browser/render_process_host.h" 40 #include "content/public/browser/render_process_host.h"
41 #include "content/public/common/content_client.h" 41 #include "content/public/common/content_client.h"
42 #include "content/public/common/content_switches.h" 42 #include "content/public/common/content_switches.h"
43 #include "content/public/common/push_event_payload.h"
43 #include "content/public/common/result_codes.h" 44 #include "content/public/common/result_codes.h"
44 #include "content/public/common/service_registry.h" 45 #include "content/public/common/service_registry.h"
45 #include "mojo/common/common_type_converters.h" 46 #include "mojo/common/common_type_converters.h"
46 #include "mojo/common/url_type_converters.h" 47 #include "mojo/common/url_type_converters.h"
47 #include "net/http/http_response_headers.h" 48 #include "net/http/http_response_headers.h"
48 #include "net/http/http_response_info.h" 49 #include "net/http/http_response_info.h"
49 50
50 namespace content { 51 namespace content {
51 52
52 using StatusCallback = ServiceWorkerVersion::StatusCallback; 53 using StatusCallback = ServiceWorkerVersion::StatusCallback;
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 ServiceWorkerStatusCode status = 650 ServiceWorkerStatusCode status =
650 embedded_worker_->SendMessage(ServiceWorkerMsg_NotificationClickEvent( 651 embedded_worker_->SendMessage(ServiceWorkerMsg_NotificationClickEvent(
651 request_id, persistent_notification_id, notification_data, 652 request_id, persistent_notification_id, notification_data,
652 action_index)); 653 action_index));
653 if (status != SERVICE_WORKER_OK) { 654 if (status != SERVICE_WORKER_OK) {
654 notification_click_requests_.Remove(request_id); 655 notification_click_requests_.Remove(request_id);
655 RunSoon(base::Bind(callback, status)); 656 RunSoon(base::Bind(callback, status));
656 } 657 }
657 } 658 }
658 659
659 void ServiceWorkerVersion::DispatchPushEvent(const StatusCallback& callback, 660 void ServiceWorkerVersion::DispatchPushEvent(
660 const std::string& data) { 661 const StatusCallback& callback,
662 const content::PushEventPayload& payload) {
Peter Beverloo 2016/01/26 12:35:18 s/content:://
harkness 2016/01/26 14:49:20 Done.
661 OnBeginEvent(); 663 OnBeginEvent();
662 DCHECK_EQ(ACTIVATED, status()) << status(); 664 DCHECK_EQ(ACTIVATED, status()) << status();
663 if (running_status() != RUNNING) { 665 if (running_status() != RUNNING) {
664 // Schedule calling this method after starting the worker. 666 // Schedule calling this method after starting the worker.
665 StartWorker(base::Bind(&RunTaskAfterStartWorker, 667 StartWorker(base::Bind(
666 weak_factory_.GetWeakPtr(), callback, 668 &RunTaskAfterStartWorker, weak_factory_.GetWeakPtr(), callback,
667 base::Bind(&self::DispatchPushEvent, 669 base::Bind(&self::DispatchPushEvent, weak_factory_.GetWeakPtr(),
668 weak_factory_.GetWeakPtr(), 670 callback, payload)));
669 callback, data)));
670 return; 671 return;
671 } 672 }
672 673
673 int request_id = AddRequest(callback, &push_requests_, REQUEST_PUSH, 674 int request_id = AddRequest(callback, &push_requests_, REQUEST_PUSH,
674 ServiceWorkerMetrics::EventType::PUSH); 675 ServiceWorkerMetrics::EventType::PUSH);
675 ServiceWorkerStatusCode status = embedded_worker_->SendMessage( 676 ServiceWorkerStatusCode status = embedded_worker_->SendMessage(
676 ServiceWorkerMsg_PushEvent(request_id, data)); 677 ServiceWorkerMsg_PushEvent(request_id, payload));
677 if (status != SERVICE_WORKER_OK) { 678 if (status != SERVICE_WORKER_OK) {
678 push_requests_.Remove(request_id); 679 push_requests_.Remove(request_id);
679 RunSoon(base::Bind(callback, status)); 680 RunSoon(base::Bind(callback, status));
680 } 681 }
681 } 682 }
682 683
683 void ServiceWorkerVersion::DispatchCrossOriginMessageEvent( 684 void ServiceWorkerVersion::DispatchCrossOriginMessageEvent(
684 const NavigatorConnectClient& client, 685 const NavigatorConnectClient& client,
685 const base::string16& message, 686 const base::string16& message,
686 const std::vector<TransferredMessagePort>& sent_message_ports, 687 const std::vector<TransferredMessagePort>& sent_message_ports,
(...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1978 void ServiceWorkerVersion::OnBeginEvent() { 1979 void ServiceWorkerVersion::OnBeginEvent() {
1979 if (should_exclude_from_uma_ || running_status() != RUNNING || 1980 if (should_exclude_from_uma_ || running_status() != RUNNING ||
1980 idle_time_.is_null()) { 1981 idle_time_.is_null()) {
1981 return; 1982 return;
1982 } 1983 }
1983 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - 1984 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() -
1984 idle_time_); 1985 idle_time_);
1985 } 1986 }
1986 1987
1987 } // namespace content 1988 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698