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

Side by Side Diff: content/renderer/service_worker/service_worker_script_context.cc

Issue 538913002: ServiceWorker: Insert TRACE_EVENT to watch a breakdown of the ServiceWorker's performance on chome:… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary include Created 6 years, 3 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
« no previous file with comments | « content/renderer/service_worker/embedded_worker_dispatcher.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/renderer/service_worker/service_worker_script_context.h" 5 #include "content/renderer/service_worker/service_worker_script_context.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 10 #include "base/logging.h"
10 #include "content/child/thread_safe_sender.h" 11 #include "content/child/thread_safe_sender.h"
11 #include "content/child/webmessageportchannel_impl.h" 12 #include "content/child/webmessageportchannel_impl.h"
12 #include "content/common/service_worker/service_worker_messages.h" 13 #include "content/common/service_worker/service_worker_messages.h"
13 #include "content/renderer/service_worker/embedded_worker_context_client.h" 14 #include "content/renderer/service_worker/embedded_worker_context_client.h"
14 #include "ipc/ipc_message.h" 15 #include "ipc/ipc_message.h"
15 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" 16 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
16 #include "third_party/WebKit/public/platform/WebServiceWorkerRequest.h" 17 #include "third_party/WebKit/public/platform/WebServiceWorkerRequest.h"
17 #include "third_party/WebKit/public/platform/WebString.h" 18 #include "third_party/WebKit/public/platform/WebString.h"
18 #include "third_party/WebKit/public/platform/WebURL.h" 19 #include "third_party/WebKit/public/platform/WebURL.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 122
122 void ServiceWorkerScriptContext::Send(IPC::Message* message) { 123 void ServiceWorkerScriptContext::Send(IPC::Message* message) {
123 embedded_context_->Send(message); 124 embedded_context_->Send(message);
124 } 125 }
125 126
126 int ServiceWorkerScriptContext::GetRoutingID() const { 127 int ServiceWorkerScriptContext::GetRoutingID() const {
127 return embedded_context_->embedded_worker_id(); 128 return embedded_context_->embedded_worker_id();
128 } 129 }
129 130
130 void ServiceWorkerScriptContext::OnActivateEvent(int request_id) { 131 void ServiceWorkerScriptContext::OnActivateEvent(int request_id) {
132 TRACE_EVENT0("ServiceWorker",
133 "ServiceWorkerScriptContext::OnActivateEvent");
131 proxy_->dispatchActivateEvent(request_id); 134 proxy_->dispatchActivateEvent(request_id);
132 } 135 }
133 136
134 void ServiceWorkerScriptContext::OnInstallEvent(int request_id, 137 void ServiceWorkerScriptContext::OnInstallEvent(int request_id,
135 int active_version_id) { 138 int active_version_id) {
139 TRACE_EVENT0("ServiceWorker",
140 "ServiceWorkerScriptContext::OnInstallEvent");
136 proxy_->dispatchInstallEvent(request_id); 141 proxy_->dispatchInstallEvent(request_id);
137 } 142 }
138 143
139 void ServiceWorkerScriptContext::OnFetchEvent( 144 void ServiceWorkerScriptContext::OnFetchEvent(
140 int request_id, 145 int request_id,
141 const ServiceWorkerFetchRequest& request) { 146 const ServiceWorkerFetchRequest& request) {
142 blink::WebServiceWorkerRequest webRequest; 147 blink::WebServiceWorkerRequest webRequest;
148 TRACE_EVENT0("ServiceWorker",
149 "ServiceWorkerScriptContext::OnFetchEvent");
143 webRequest.setURL(blink::WebURL(request.url)); 150 webRequest.setURL(blink::WebURL(request.url));
144 webRequest.setMethod(blink::WebString::fromUTF8(request.method)); 151 webRequest.setMethod(blink::WebString::fromUTF8(request.method));
145 for (std::map<std::string, std::string>::const_iterator it = 152 for (std::map<std::string, std::string>::const_iterator it =
146 request.headers.begin(); 153 request.headers.begin();
147 it != request.headers.end(); 154 it != request.headers.end();
148 ++it) { 155 ++it) {
149 webRequest.setHeader(blink::WebString::fromUTF8(it->first), 156 webRequest.setHeader(blink::WebString::fromUTF8(it->first),
150 blink::WebString::fromUTF8(it->second)); 157 blink::WebString::fromUTF8(it->second));
151 } 158 }
152 if (!request.blob_uuid.empty()) { 159 if (!request.blob_uuid.empty()) {
153 webRequest.setBlob(blink::WebString::fromUTF8(request.blob_uuid), 160 webRequest.setBlob(blink::WebString::fromUTF8(request.blob_uuid),
154 request.blob_size); 161 request.blob_size);
155 } 162 }
156 webRequest.setReferrer(blink::WebString::fromUTF8(request.referrer.spec()), 163 webRequest.setReferrer(blink::WebString::fromUTF8(request.referrer.spec()),
157 blink::WebReferrerPolicyDefault); 164 blink::WebReferrerPolicyDefault);
158 webRequest.setIsReload(request.is_reload); 165 webRequest.setIsReload(request.is_reload);
159 proxy_->dispatchFetchEvent(request_id, webRequest); 166 proxy_->dispatchFetchEvent(request_id, webRequest);
160 } 167 }
161 168
162 void ServiceWorkerScriptContext::OnSyncEvent(int request_id) { 169 void ServiceWorkerScriptContext::OnSyncEvent(int request_id) {
170 TRACE_EVENT0("ServiceWorker",
171 "ServiceWorkerScriptContext::OnSyncEvent");
163 proxy_->dispatchSyncEvent(request_id); 172 proxy_->dispatchSyncEvent(request_id);
164 } 173 }
165 174
166 void ServiceWorkerScriptContext::OnPushEvent(int request_id, 175 void ServiceWorkerScriptContext::OnPushEvent(int request_id,
167 const std::string& data) { 176 const std::string& data) {
177 TRACE_EVENT0("ServiceWorker",
178 "ServiceWorkerScriptContext::OnPushEvent");
168 proxy_->dispatchPushEvent(request_id, blink::WebString::fromUTF8(data)); 179 proxy_->dispatchPushEvent(request_id, blink::WebString::fromUTF8(data));
169 Send(new ServiceWorkerHostMsg_PushEventFinished( 180 Send(new ServiceWorkerHostMsg_PushEventFinished(
170 GetRoutingID(), request_id)); 181 GetRoutingID(), request_id));
171 } 182 }
172 183
173 void ServiceWorkerScriptContext::OnPostMessage( 184 void ServiceWorkerScriptContext::OnPostMessage(
174 const base::string16& message, 185 const base::string16& message,
175 const std::vector<int>& sent_message_port_ids, 186 const std::vector<int>& sent_message_port_ids,
176 const std::vector<int>& new_routing_ids) { 187 const std::vector<int>& new_routing_ids) {
188 TRACE_EVENT0("ServiceWorker",
189 "ServiceWorkerScriptContext::OnPostEvent");
177 std::vector<WebMessagePortChannelImpl*> ports; 190 std::vector<WebMessagePortChannelImpl*> ports;
178 if (!sent_message_port_ids.empty()) { 191 if (!sent_message_port_ids.empty()) {
179 base::MessageLoopProxy* loop_proxy = embedded_context_->main_thread_proxy(); 192 base::MessageLoopProxy* loop_proxy = embedded_context_->main_thread_proxy();
180 ports.resize(sent_message_port_ids.size()); 193 ports.resize(sent_message_port_ids.size());
181 for (size_t i = 0; i < sent_message_port_ids.size(); ++i) { 194 for (size_t i = 0; i < sent_message_port_ids.size(); ++i) {
182 ports[i] = new WebMessagePortChannelImpl( 195 ports[i] = new WebMessagePortChannelImpl(
183 new_routing_ids[i], sent_message_port_ids[i], loop_proxy); 196 new_routing_ids[i], sent_message_port_ids[i], loop_proxy);
184 } 197 }
185 } 198 }
186 199
187 proxy_->dispatchMessageEvent(message, ports); 200 proxy_->dispatchMessageEvent(message, ports);
188 } 201 }
189 202
190 void ServiceWorkerScriptContext::OnDidGetClientDocuments( 203 void ServiceWorkerScriptContext::OnDidGetClientDocuments(
191 int request_id, const std::vector<int>& client_ids) { 204 int request_id, const std::vector<int>& client_ids) {
205 TRACE_EVENT0("ServiceWorker",
206 "ServiceWorkerScriptContext::OnDidGetClientDocuments");
192 blink::WebServiceWorkerClientsCallbacks* callbacks = 207 blink::WebServiceWorkerClientsCallbacks* callbacks =
193 pending_clients_callbacks_.Lookup(request_id); 208 pending_clients_callbacks_.Lookup(request_id);
194 if (!callbacks) { 209 if (!callbacks) {
195 NOTREACHED() << "Got stray response: " << request_id; 210 NOTREACHED() << "Got stray response: " << request_id;
196 return; 211 return;
197 } 212 }
198 scoped_ptr<blink::WebServiceWorkerClientsInfo> info( 213 scoped_ptr<blink::WebServiceWorkerClientsInfo> info(
199 new blink::WebServiceWorkerClientsInfo); 214 new blink::WebServiceWorkerClientsInfo);
200 info->clientIDs = client_ids; 215 info->clientIDs = client_ids;
201 callbacks->onSuccess(info.release()); 216 callbacks->onSuccess(info.release());
202 pending_clients_callbacks_.Remove(request_id); 217 pending_clients_callbacks_.Remove(request_id);
203 } 218 }
204 219
205 } // namespace content 220 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/service_worker/embedded_worker_dispatcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698