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

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

Issue 931173002: Implement EmbeddedWorkerContextClient.setCachedMetadata/clearCachedMetadata (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix clang failure Created 5 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 "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/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/time/time.h"
12 #include "content/browser/message_port_message_filter.h" 13 #include "content/browser/message_port_message_filter.h"
13 #include "content/browser/message_port_service.h" 14 #include "content/browser/message_port_service.h"
14 #include "content/browser/service_worker/embedded_worker_instance.h" 15 #include "content/browser/service_worker/embedded_worker_instance.h"
15 #include "content/browser/service_worker/embedded_worker_registry.h" 16 #include "content/browser/service_worker/embedded_worker_registry.h"
16 #include "content/browser/service_worker/service_worker_context_core.h" 17 #include "content/browser/service_worker/service_worker_context_core.h"
17 #include "content/browser/service_worker/service_worker_context_wrapper.h" 18 #include "content/browser/service_worker/service_worker_context_wrapper.h"
18 #include "content/browser/service_worker/service_worker_registration.h" 19 #include "content/browser/service_worker/service_worker_registration.h"
19 #include "content/browser/service_worker/service_worker_utils.h" 20 #include "content/browser/service_worker/service_worker_utils.h"
20 #include "content/browser/storage_partition_impl.h" 21 #include "content/browser/storage_partition_impl.h"
21 #include "content/common/service_worker/service_worker_messages.h" 22 #include "content/common/service_worker/service_worker_messages.h"
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 265
265 void KillEmbeddedWorkerProcess(int process_id, ResultCode code) { 266 void KillEmbeddedWorkerProcess(int process_id, ResultCode code) {
266 DCHECK_CURRENTLY_ON(BrowserThread::UI); 267 DCHECK_CURRENTLY_ON(BrowserThread::UI);
267 268
268 RenderProcessHost* render_process_host = 269 RenderProcessHost* render_process_host =
269 RenderProcessHost::FromID(process_id); 270 RenderProcessHost::FromID(process_id);
270 if (render_process_host->GetHandle() != base::kNullProcessHandle) 271 if (render_process_host->GetHandle() != base::kNullProcessHandle)
271 render_process_host->ReceivedBadMessage(); 272 render_process_host->ReceivedBadMessage();
272 } 273 }
273 274
275 void DidSetCachedMetadata(int64 callback_id, int result) {
276 TRACE_EVENT_ASYNC_END1("ServiceWorker",
277 "ServiceWorkerVersion::OnSetCachedMetadata",
278 callback_id, "result", result);
279 }
280
281 void DidClearCachedMetadata(int64 callback_id, int result) {
282 TRACE_EVENT_ASYNC_END1("ServiceWorker",
283 "ServiceWorkerVersion::OnClearCachedMetadata",
284 callback_id, "result", result);
285 }
286
274 } // namespace 287 } // namespace
275 288
276 ServiceWorkerVersion::ServiceWorkerVersion( 289 ServiceWorkerVersion::ServiceWorkerVersion(
277 ServiceWorkerRegistration* registration, 290 ServiceWorkerRegistration* registration,
278 const GURL& script_url, 291 const GURL& script_url,
279 int64 version_id, 292 int64 version_id,
280 base::WeakPtr<ServiceWorkerContextCore> context) 293 base::WeakPtr<ServiceWorkerContextCore> context)
281 : version_id_(version_id), 294 : version_id_(version_id),
282 registration_id_(kInvalidServiceWorkerVersionId), 295 registration_id_(kInvalidServiceWorkerVersionId),
283 script_url_(script_url), 296 script_url_(script_url),
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_NotificationClickEventFinished, 921 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_NotificationClickEventFinished,
909 OnNotificationClickEventFinished) 922 OnNotificationClickEventFinished)
910 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_PushEventFinished, 923 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_PushEventFinished,
911 OnPushEventFinished) 924 OnPushEventFinished)
912 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_GeofencingEventFinished, 925 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_GeofencingEventFinished,
913 OnGeofencingEventFinished) 926 OnGeofencingEventFinished)
914 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_CrossOriginConnectEventFinished, 927 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_CrossOriginConnectEventFinished,
915 OnCrossOriginConnectEventFinished) 928 OnCrossOriginConnectEventFinished)
916 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_OpenWindow, 929 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_OpenWindow,
917 OnOpenWindow) 930 OnOpenWindow)
931 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_SetCachedMetadata,
932 OnSetCachedMetadata)
933 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ClearCachedMetadata,
934 OnClearCachedMetadata)
918 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_PostMessageToDocument, 935 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_PostMessageToDocument,
919 OnPostMessageToDocument) 936 OnPostMessageToDocument)
920 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_FocusClient, 937 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_FocusClient,
921 OnFocusClient) 938 OnFocusClient)
922 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_SkipWaiting, 939 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_SkipWaiting,
923 OnSkipWaiting) 940 OnSkipWaiting)
924 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ClaimClients, 941 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ClaimClients,
925 OnClaimClients) 942 OnClaimClients)
926 IPC_MESSAGE_UNHANDLED(handled = false) 943 IPC_MESSAGE_UNHANDLED(handled = false)
927 IPC_END_MESSAGE_MAP() 944 IPC_END_MESSAGE_MAP()
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 // If the |client_info| is empty, it means that the opened window wasn't 1230 // If the |client_info| is empty, it means that the opened window wasn't
1214 // controlled but the action still succeeded. The renderer process is 1231 // controlled but the action still succeeded. The renderer process is
1215 // expecting an empty client in such case. 1232 // expecting an empty client in such case.
1216 if (!client.IsEmpty()) 1233 if (!client.IsEmpty())
1217 client.client_id = client_id; 1234 client.client_id = client_id;
1218 1235
1219 embedded_worker_->SendMessage(ServiceWorkerMsg_OpenWindowResponse( 1236 embedded_worker_->SendMessage(ServiceWorkerMsg_OpenWindowResponse(
1220 request_id, client)); 1237 request_id, client));
1221 } 1238 }
1222 1239
1240 void ServiceWorkerVersion::OnSetCachedMetadata(const GURL& url,
1241 const std::vector<char>& data) {
1242 int64 callback_id = base::TimeTicks::Now().ToInternalValue();
1243 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker",
1244 "ServiceWorkerVersion::OnSetCachedMetadata",
1245 callback_id, "URL", url.spec());
1246 script_cache_map_.WriteMetadata(
1247 url, data, base::Bind(&DidSetCachedMetadata, callback_id));
1248 }
1249
1250 void ServiceWorkerVersion::OnClearCachedMetadata(const GURL& url) {
1251 int64 callback_id = base::TimeTicks::Now().ToInternalValue();
1252 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker",
1253 "ServiceWorkerVersion::OnClearCachedMetadata",
1254 callback_id, "URL", url.spec());
1255 script_cache_map_.ClearMetadata(
1256 url, base::Bind(&DidClearCachedMetadata, callback_id));
1257 }
1258
1223 void ServiceWorkerVersion::OnPostMessageToDocument( 1259 void ServiceWorkerVersion::OnPostMessageToDocument(
1224 int client_id, 1260 int client_id,
1225 const base::string16& message, 1261 const base::string16& message,
1226 const std::vector<int>& sent_message_port_ids) { 1262 const std::vector<int>& sent_message_port_ids) {
1227 TRACE_EVENT1("ServiceWorker", 1263 TRACE_EVENT1("ServiceWorker",
1228 "ServiceWorkerVersion::OnPostMessageToDocument", 1264 "ServiceWorkerVersion::OnPostMessageToDocument",
1229 "Client id", client_id); 1265 "Client id", client_id);
1230 ServiceWorkerProviderHost* provider_host = 1266 ServiceWorkerProviderHost* provider_host =
1231 controllee_by_id_.Lookup(client_id); 1267 controllee_by_id_.Lookup(client_id);
1232 if (!provider_host) { 1268 if (!provider_host) {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 int request_id) { 1444 int request_id) {
1409 callbacks->Remove(request_id); 1445 callbacks->Remove(request_id);
1410 if (is_doomed_) { 1446 if (is_doomed_) {
1411 // The stop should be already scheduled, but try to stop immediately, in 1447 // The stop should be already scheduled, but try to stop immediately, in
1412 // order to release worker resources soon. 1448 // order to release worker resources soon.
1413 StopWorkerIfIdle(); 1449 StopWorkerIfIdle();
1414 } 1450 }
1415 } 1451 }
1416 1452
1417 } // namespace content 1453 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698