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

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

Issue 1439333002: Service Worker: Add Clients.get(id) (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 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 source_identifier, 948 source_identifier,
949 message_level, 949 message_level,
950 message, 950 message,
951 line_number, 951 line_number,
952 source_url)); 952 source_url));
953 } 953 }
954 954
955 bool ServiceWorkerVersion::OnMessageReceived(const IPC::Message& message) { 955 bool ServiceWorkerVersion::OnMessageReceived(const IPC::Message& message) {
956 bool handled = true; 956 bool handled = true;
957 IPC_BEGIN_MESSAGE_MAP(ServiceWorkerVersion, message) 957 IPC_BEGIN_MESSAGE_MAP(ServiceWorkerVersion, message)
958 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_GetClient, OnGetClient)
958 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_GetClients, 959 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_GetClients,
959 OnGetClients) 960 OnGetClients)
960 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ActivateEventFinished, 961 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ActivateEventFinished,
961 OnActivateEventFinished) 962 OnActivateEventFinished)
962 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_InstallEventFinished, 963 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_InstallEventFinished,
963 OnInstallEventFinished) 964 OnInstallEventFinished)
964 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_FetchEventFinished, 965 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_FetchEventFinished,
965 OnFetchEventFinished) 966 OnFetchEventFinished)
966 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_OpenWindow, 967 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_OpenWindow,
967 OnOpenWindow) 968 OnOpenWindow)
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 int request_id = AddRequest(callback, &activate_requests_, REQUEST_ACTIVATE, 1019 int request_id = AddRequest(callback, &activate_requests_, REQUEST_ACTIVATE,
1019 ServiceWorkerMetrics::EventType::ACTIVATE); 1020 ServiceWorkerMetrics::EventType::ACTIVATE);
1020 ServiceWorkerStatusCode status = 1021 ServiceWorkerStatusCode status =
1021 embedded_worker_->SendMessage(ServiceWorkerMsg_ActivateEvent(request_id)); 1022 embedded_worker_->SendMessage(ServiceWorkerMsg_ActivateEvent(request_id));
1022 if (status != SERVICE_WORKER_OK) { 1023 if (status != SERVICE_WORKER_OK) {
1023 activate_requests_.Remove(request_id); 1024 activate_requests_.Remove(request_id);
1024 RunSoon(base::Bind(callback, status)); 1025 RunSoon(base::Bind(callback, status));
1025 } 1026 }
1026 } 1027 }
1027 1028
1029 void ServiceWorkerVersion::OnGetClient(int request_id, const std::string& id) {
nhiroki 2016/02/08 06:27:02 id -> client_uuid
jungkees 2016/02/12 15:03:21 Done.
1030 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", "ServiceWorkerVersion::OnGetClient",
1031 request_id, "id", id);
nhiroki 2016/02/08 06:27:02 ditto.
jungkees 2016/02/12 15:03:21 Done.
1032 service_worker_client_utils::GetClient(
1033 weak_factory_.GetWeakPtr(), id, context_,
1034 base::Bind(&ServiceWorkerVersion::OnGetClientFinished,
1035 weak_factory_.GetWeakPtr(), request_id));
1036 }
1037
1038 void ServiceWorkerVersion::OnGetClientFinished(
zino 2016/02/05 06:21:44 If you modify this callback to take client_uuid, y
jungkees 2016/02/12 15:03:21 If I change GetClientInfoCallback to take |client_
1039 int request_id,
1040 const ServiceWorkerClientInfo& client) {
1041 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1042 TRACE_EVENT_ASYNC_END1("ServiceWorker", "ServiceWorkerVersion::OnGetClient",
1043 request_id, "The retrieved client", &client);
nhiroki 2016/02/08 06:27:02 |&client| might not be very useful for investigati
jungkees 2016/02/12 15:03:21 Addressed. Thanks.
1044
1045 // When Clients.matchAll() is called on the script evaluation phase, the
1046 // running status can be STARTING here.
1047 if (running_status() != STARTING && running_status() != RUNNING)
1048 return;
1049
1050 embedded_worker_->SendMessage(
1051 ServiceWorkerMsg_DidGetClient(request_id, client));
1052 }
1053
1028 void ServiceWorkerVersion::OnGetClients( 1054 void ServiceWorkerVersion::OnGetClients(
1029 int request_id, 1055 int request_id,
1030 const ServiceWorkerClientQueryOptions& options) { 1056 const ServiceWorkerClientQueryOptions& options) {
1031 TRACE_EVENT_ASYNC_BEGIN2( 1057 TRACE_EVENT_ASYNC_BEGIN2(
1032 "ServiceWorker", "ServiceWorkerVersion::OnGetClients", request_id, 1058 "ServiceWorker", "ServiceWorkerVersion::OnGetClients", request_id,
1033 "client_type", options.client_type, "include_uncontrolled", 1059 "client_type", options.client_type, "include_uncontrolled",
1034 options.include_uncontrolled); 1060 options.include_uncontrolled);
1035 service_worker_client_utils::GetClients( 1061 service_worker_client_utils::GetClients(
1036 weak_factory_.GetWeakPtr(), options, 1062 weak_factory_.GetWeakPtr(), options,
1037 base::Bind(&ServiceWorkerVersion::OnGetClientsFinished, 1063 base::Bind(&ServiceWorkerVersion::OnGetClientsFinished,
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 void ServiceWorkerVersion::OnBeginEvent() { 1957 void ServiceWorkerVersion::OnBeginEvent() {
1932 if (should_exclude_from_uma_ || running_status() != RUNNING || 1958 if (should_exclude_from_uma_ || running_status() != RUNNING ||
1933 idle_time_.is_null()) { 1959 idle_time_.is_null()) {
1934 return; 1960 return;
1935 } 1961 }
1936 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - 1962 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() -
1937 idle_time_); 1963 idle_time_);
1938 } 1964 }
1939 1965
1940 } // namespace content 1966 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698