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

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

Issue 2905593002: Clients.matchAll() should return ordered clients by type/focus time/creation time (Closed)
Patch Set: Totally follow the matchAll specification Created 3 years, 7 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 | « no previous file | content/browser/service_worker/service_worker_provider_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_client_utils.h" 5 #include "content/browser/service_worker/service_worker_client_utils.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <tuple> 8 #include <tuple>
9 9
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 int frame_tree_node_id_; 96 int frame_tree_node_id_;
97 const OpenURLCallback callback_; 97 const OpenURLCallback callback_;
98 98
99 DISALLOW_COPY_AND_ASSIGN(OpenURLObserver); 99 DISALLOW_COPY_AND_ASSIGN(OpenURLObserver);
100 }; 100 };
101 101
102 ServiceWorkerClientInfo GetWindowClientInfoOnUI( 102 ServiceWorkerClientInfo GetWindowClientInfoOnUI(
103 int render_process_id, 103 int render_process_id,
104 int render_frame_id, 104 int render_frame_id,
105 base::TimeTicks create_time,
105 const std::string& client_uuid) { 106 const std::string& client_uuid) {
106 DCHECK_CURRENTLY_ON(BrowserThread::UI); 107 DCHECK_CURRENTLY_ON(BrowserThread::UI);
107 RenderFrameHostImpl* render_frame_host = 108 RenderFrameHostImpl* render_frame_host =
108 RenderFrameHostImpl::FromID(render_process_id, render_frame_id); 109 RenderFrameHostImpl::FromID(render_process_id, render_frame_id);
109 if (!render_frame_host) 110 if (!render_frame_host)
110 return ServiceWorkerClientInfo(); 111 return ServiceWorkerClientInfo();
111 112
112 // TODO(mlamouri,michaeln): it is possible to end up collecting information 113 // TODO(mlamouri,michaeln): it is possible to end up collecting information
113 // for a frame that is actually being navigated and isn't exactly what we are 114 // for a frame that is actually being navigated and isn't exactly what we are
114 // expecting. 115 // expecting.
115 return ServiceWorkerClientInfo( 116 return ServiceWorkerClientInfo(
116 client_uuid, render_frame_host->GetVisibilityState(), 117 client_uuid, render_frame_host->GetVisibilityState(),
117 render_frame_host->IsFocused(), render_frame_host->GetLastCommittedURL(), 118 render_frame_host->IsFocused(), render_frame_host->GetLastCommittedURL(),
118 render_frame_host->GetParent() ? REQUEST_CONTEXT_FRAME_TYPE_NESTED 119 render_frame_host->GetParent() ? REQUEST_CONTEXT_FRAME_TYPE_NESTED
119 : REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL, 120 : REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL,
120 render_frame_host->frame_tree_node()->last_focus_time(), 121 render_frame_host->frame_tree_node()->last_focus_time(), create_time,
121 blink::kWebServiceWorkerClientTypeWindow); 122 blink::kWebServiceWorkerClientTypeWindow);
122 } 123 }
123 124
124 ServiceWorkerClientInfo FocusOnUI(int render_process_id, 125 ServiceWorkerClientInfo FocusOnUI(int render_process_id,
125 int render_frame_id, 126 int render_frame_id,
127 base::TimeTicks create_time,
126 const std::string& client_uuid) { 128 const std::string& client_uuid) {
127 DCHECK_CURRENTLY_ON(BrowserThread::UI); 129 DCHECK_CURRENTLY_ON(BrowserThread::UI);
128 RenderFrameHostImpl* render_frame_host = 130 RenderFrameHostImpl* render_frame_host =
129 RenderFrameHostImpl::FromID(render_process_id, render_frame_id); 131 RenderFrameHostImpl::FromID(render_process_id, render_frame_id);
130 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( 132 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(
131 WebContents::FromRenderFrameHost(render_frame_host)); 133 WebContents::FromRenderFrameHost(render_frame_host));
132 134
133 if (!render_frame_host || !web_contents) 135 if (!render_frame_host || !web_contents)
134 return ServiceWorkerClientInfo(); 136 return ServiceWorkerClientInfo();
135 137
136 FrameTreeNode* frame_tree_node = render_frame_host->frame_tree_node(); 138 FrameTreeNode* frame_tree_node = render_frame_host->frame_tree_node();
137 139
138 // Focus the frame in the frame tree node, in case it has changed. 140 // Focus the frame in the frame tree node, in case it has changed.
139 frame_tree_node->frame_tree()->SetFocusedFrame( 141 frame_tree_node->frame_tree()->SetFocusedFrame(
140 frame_tree_node, render_frame_host->GetSiteInstance()); 142 frame_tree_node, render_frame_host->GetSiteInstance());
141 143
142 // Focus the frame's view to make sure the frame is now considered as focused. 144 // Focus the frame's view to make sure the frame is now considered as focused.
143 render_frame_host->GetView()->Focus(); 145 render_frame_host->GetView()->Focus();
144 146
145 // Move the web contents to the foreground. 147 // Move the web contents to the foreground.
146 web_contents->Activate(); 148 web_contents->Activate();
147 149
148 return GetWindowClientInfoOnUI(render_process_id, render_frame_id, 150 return GetWindowClientInfoOnUI(render_process_id, render_frame_id,
149 client_uuid); 151 create_time, client_uuid);
150 } 152 }
151 153
152 // This is only called for main frame navigations in OpenWindowOnUI(). 154 // This is only called for main frame navigations in OpenWindowOnUI().
153 void DidOpenURLOnUI(const OpenURLCallback& callback, 155 void DidOpenURLOnUI(const OpenURLCallback& callback,
154 WebContents* web_contents) { 156 WebContents* web_contents) {
155 DCHECK_CURRENTLY_ON(BrowserThread::UI); 157 DCHECK_CURRENTLY_ON(BrowserThread::UI);
156 158
157 if (!web_contents) { 159 if (!web_contents) {
158 BrowserThread::PostTask( 160 BrowserThread::PostTask(
159 BrowserThread::IO, FROM_HERE, 161 BrowserThread::IO, FROM_HERE,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 context->GetClientProviderHostIterator(origin); 269 context->GetClientProviderHostIterator(origin);
268 !it->IsAtEnd(); it->Advance()) { 270 !it->IsAtEnd(); it->Advance()) {
269 ServiceWorkerProviderHost* provider_host = it->GetProviderHost(); 271 ServiceWorkerProviderHost* provider_host = it->GetProviderHost();
270 if (provider_host->process_id() != render_process_id || 272 if (provider_host->process_id() != render_process_id ||
271 provider_host->frame_id() != render_frame_id) { 273 provider_host->frame_id() != render_frame_id) {
272 continue; 274 continue;
273 } 275 }
274 BrowserThread::PostTaskAndReplyWithResult( 276 BrowserThread::PostTaskAndReplyWithResult(
275 BrowserThread::UI, FROM_HERE, 277 BrowserThread::UI, FROM_HERE,
276 base::Bind(&GetWindowClientInfoOnUI, provider_host->process_id(), 278 base::Bind(&GetWindowClientInfoOnUI, provider_host->process_id(),
277 provider_host->route_id(), provider_host->client_uuid()), 279 provider_host->route_id(), provider_host->create_time(),
280 provider_host->client_uuid()),
278 base::Bind(callback, SERVICE_WORKER_OK)); 281 base::Bind(callback, SERVICE_WORKER_OK));
279 return; 282 return;
280 } 283 }
281 284
282 // If here, it means that no provider_host was found, in which case, the 285 // If here, it means that no provider_host was found, in which case, the
283 // renderer should still be informed that the window was opened. 286 // renderer should still be informed that the window was opened.
284 callback.Run(SERVICE_WORKER_OK, ServiceWorkerClientInfo()); 287 callback.Run(SERVICE_WORKER_OK, ServiceWorkerClientInfo());
285 } 288 }
286 289
287 void AddWindowClient( 290 void AddWindowClient(
288 ServiceWorkerProviderHost* host, 291 ServiceWorkerProviderHost* host,
289 std::vector<std::tuple<int, int, std::string>>* client_info) { 292 std::vector<std::tuple<int, int, base::TimeTicks, std::string>>*
293 client_info) {
290 DCHECK_CURRENTLY_ON(BrowserThread::IO); 294 DCHECK_CURRENTLY_ON(BrowserThread::IO);
291 if (host->client_type() != blink::kWebServiceWorkerClientTypeWindow) 295 if (host->client_type() != blink::kWebServiceWorkerClientTypeWindow)
292 return; 296 return;
293 client_info->push_back(std::make_tuple(host->process_id(), host->frame_id(), 297 client_info->push_back(std::make_tuple(host->process_id(), host->frame_id(),
298 host->create_time(),
294 host->client_uuid())); 299 host->client_uuid()));
295 } 300 }
296 301
297 void AddNonWindowClient(ServiceWorkerProviderHost* host, 302 void AddNonWindowClient(ServiceWorkerProviderHost* host,
298 const ServiceWorkerClientQueryOptions& options, 303 const ServiceWorkerClientQueryOptions& options,
299 ServiceWorkerClients* clients) { 304 ServiceWorkerClients* clients) {
300 DCHECK_CURRENTLY_ON(BrowserThread::IO); 305 DCHECK_CURRENTLY_ON(BrowserThread::IO);
301 blink::WebServiceWorkerClientType host_client_type = host->client_type(); 306 blink::WebServiceWorkerClientType host_client_type = host->client_type();
302 if (host_client_type == blink::kWebServiceWorkerClientTypeWindow) 307 if (host_client_type == blink::kWebServiceWorkerClientTypeWindow)
303 return; 308 return;
304 if (options.client_type != blink::kWebServiceWorkerClientTypeAll && 309 if (options.client_type != blink::kWebServiceWorkerClientTypeAll &&
305 options.client_type != host_client_type) 310 options.client_type != host_client_type)
306 return; 311 return;
307 312
308 ServiceWorkerClientInfo client_info( 313 ServiceWorkerClientInfo client_info(
309 host->client_uuid(), blink::kWebPageVisibilityStateHidden, 314 host->client_uuid(), blink::kWebPageVisibilityStateHidden,
310 false, // is_focused 315 false, // is_focused
311 host->document_url(), REQUEST_CONTEXT_FRAME_TYPE_NONE, base::TimeTicks(), 316 host->document_url(), REQUEST_CONTEXT_FRAME_TYPE_NONE, base::TimeTicks(),
312 host_client_type); 317 host->create_time(), host_client_type);
313 clients->push_back(client_info); 318 clients->push_back(client_info);
314 } 319 }
315 320
316 void OnGetWindowClientsOnUI( 321 void OnGetWindowClientsOnUI(
317 // The tuple contains process_id, frame_id, client_uuid. 322 // The tuple contains process_id, frame_id, client_uuid.
318 const std::vector<std::tuple<int, int, std::string>>& clients_info, 323 const std::vector<std::tuple<int, int, base::TimeTicks, std::string>>&
324 clients_info,
319 const GURL& script_url, 325 const GURL& script_url,
320 const GetWindowClientsCallback& callback) { 326 const GetWindowClientsCallback& callback) {
321 DCHECK_CURRENTLY_ON(BrowserThread::UI); 327 DCHECK_CURRENTLY_ON(BrowserThread::UI);
322 328
323 std::unique_ptr<ServiceWorkerClients> clients(new ServiceWorkerClients); 329 std::unique_ptr<ServiceWorkerClients> clients(new ServiceWorkerClients);
shimazu 2017/05/25 08:56:26 Could you use base::MakeUnique<ServiceWorkerClient
xiaofengzhang 2017/05/26 04:01:28 Done.
324 for (const auto& it : clients_info) { 330 for (const auto& it : clients_info) {
325 ServiceWorkerClientInfo info = GetWindowClientInfoOnUI( 331 ServiceWorkerClientInfo info = GetWindowClientInfoOnUI(
326 std::get<0>(it), std::get<1>(it), std::get<2>(it)); 332 std::get<0>(it), std::get<1>(it), std::get<2>(it), std::get<3>(it));
327 333
328 // If the request to the provider_host returned an empty 334 // If the request to the provider_host returned an empty
329 // ServiceWorkerClientInfo, that means that it wasn't possible to associate 335 // ServiceWorkerClientInfo, that means that it wasn't possible to associate
330 // it with a valid RenderFrameHost. It might be because the frame was killed 336 // it with a valid RenderFrameHost. It might be because the frame was killed
331 // or navigated in between. 337 // or navigated in between.
332 if (info.IsEmpty()) 338 if (info.IsEmpty())
333 continue; 339 continue;
334 340
335 // We can get info for a frame that was navigating end ended up with a 341 // We can get info for a frame that was navigating end ended up with a
336 // different URL than expected. In such case, we should make sure to not 342 // different URL than expected. In such case, we should make sure to not
337 // expose cross-origin WindowClient. 343 // expose cross-origin WindowClient.
338 if (info.url.GetOrigin() != script_url.GetOrigin()) 344 if (info.url.GetOrigin() != script_url.GetOrigin())
339 continue; 345 continue;
340 346
341 clients->push_back(info); 347 clients->push_back(info);
342 } 348 }
343 349
344 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 350 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
345 base::Bind(callback, base::Passed(&clients))); 351 base::Bind(callback, base::Passed(&clients)));
346 } 352 }
347 353
354 struct ServiceWorkerClientTypeIsWindow {
355 bool operator()(const ServiceWorkerClientInfo& a,
356 const ServiceWorkerClientInfo& b) const {
357 return a.client_type == blink::kWebServiceWorkerClientTypeWindow;
358 }
359 };
xiaofengzhang 2017/05/26 04:01:28 Sorry, this part is not needed
shimazu 2017/05/26 08:10:07 Acknowledged.
360
348 struct ServiceWorkerClientInfoSortMRU { 361 struct ServiceWorkerClientInfoSortMRU {
349 bool operator()(const ServiceWorkerClientInfo& a, 362 bool operator()(const ServiceWorkerClientInfo& a,
350 const ServiceWorkerClientInfo& b) const { 363 const ServiceWorkerClientInfo& b) const {
351 return a.last_focus_time > b.last_focus_time; 364 return a.last_focus_time > b.last_focus_time;
352 } 365 }
353 }; 366 };
354 367
368 struct ServiceWorkerClientInfoSortCreateTime {
369 bool operator()(const ServiceWorkerClientInfo& a,
370 const ServiceWorkerClientInfo& b) const {
371 return a.create_time < b.create_time;
372 }
373 };
374
355 void DidGetClients(const ClientsCallback& callback, 375 void DidGetClients(const ClientsCallback& callback,
356 ServiceWorkerClients* clients) { 376 ServiceWorkerClients* clients) {
shimazu 2017/05/25 08:56:26 Could you change the type to std::unique_ptr<Servi
xiaofengzhang 2017/05/26 04:01:27 Done.
357 DCHECK_CURRENTLY_ON(BrowserThread::IO); 377 DCHECK_CURRENTLY_ON(BrowserThread::IO);
358 378
359 // Sort clients so that the most recently active tab is in the front. 379 // Window clients are always placed before worker clients.
360 std::sort(clients->begin(), clients->end(), ServiceWorkerClientInfoSortMRU()); 380 auto window_clients_bound = std::stable_partition(
381 clients->begin(), clients->end(), [](ServiceWorkerClientInfo info) {
shimazu 2017/05/25 08:56:26 I feel it's more simple to implement operator< in
xiaofengzhang 2017/05/26 04:01:27 Thanks shimazu. please see the cl#2. The reasons I
shimazu 2017/05/26 08:10:07 It looks good, thanks!
382 return info.client_type == blink::kWebServiceWorkerClientTypeWindow;
383 });
384
385 // Window clients that have ever been focused are placed first.
386 auto focused_bound = std::stable_partition(
387 clients->begin(), window_clients_bound, [](ServiceWorkerClientInfo info) {
388 return info.last_focus_time > base::TimeTicks();
389 });
390
391 // Sort focused window clients so that the most recently active tab is in the
392 // front.
393 std::sort(clients->begin(), focused_bound, ServiceWorkerClientInfoSortMRU());
394
395 // Sort non-focused window clients so that the earliest created tab is in the
396 // front.
397 std::sort(focused_bound, clients->end(),
398 ServiceWorkerClientInfoSortCreateTime());
399
400 // Sort worker clients so that the earliest created one is in the front.
401 std::sort(window_clients_bound, clients->end(),
402 ServiceWorkerClientInfoSortCreateTime());
361 403
362 callback.Run(clients); 404 callback.Run(clients);
363 } 405 }
364 406
365 void GetNonWindowClients(const base::WeakPtr<ServiceWorkerVersion>& controller, 407 void GetNonWindowClients(const base::WeakPtr<ServiceWorkerVersion>& controller,
366 const ServiceWorkerClientQueryOptions& options, 408 const ServiceWorkerClientQueryOptions& options,
367 ServiceWorkerClients* clients) { 409 ServiceWorkerClients* clients) {
368 DCHECK_CURRENTLY_ON(BrowserThread::IO); 410 DCHECK_CURRENTLY_ON(BrowserThread::IO);
369 if (!options.include_uncontrolled) { 411 if (!options.include_uncontrolled) {
370 for (auto& controllee : controller->controllee_map()) 412 for (auto& controllee : controller->controllee_map())
(...skipping 17 matching lines...) Expand all
388 DidGetClients(callback, clients.get()); 430 DidGetClients(callback, clients.get());
389 } 431 }
390 432
391 void GetWindowClients(const base::WeakPtr<ServiceWorkerVersion>& controller, 433 void GetWindowClients(const base::WeakPtr<ServiceWorkerVersion>& controller,
392 const ServiceWorkerClientQueryOptions& options, 434 const ServiceWorkerClientQueryOptions& options,
393 const ClientsCallback& callback) { 435 const ClientsCallback& callback) {
394 DCHECK_CURRENTLY_ON(BrowserThread::IO); 436 DCHECK_CURRENTLY_ON(BrowserThread::IO);
395 DCHECK(options.client_type == blink::kWebServiceWorkerClientTypeWindow || 437 DCHECK(options.client_type == blink::kWebServiceWorkerClientTypeWindow ||
396 options.client_type == blink::kWebServiceWorkerClientTypeAll); 438 options.client_type == blink::kWebServiceWorkerClientTypeAll);
397 439
398 std::vector<std::tuple<int, int, std::string>> clients_info; 440 std::vector<std::tuple<int, int, base::TimeTicks, std::string>> clients_info;
399 if (!options.include_uncontrolled) { 441 if (!options.include_uncontrolled) {
400 for (auto& controllee : controller->controllee_map()) 442 for (auto& controllee : controller->controllee_map()) {
401 AddWindowClient(controllee.second, &clients_info); 443 AddWindowClient(controllee.second, &clients_info);
444 }
402 } else if (controller->context()) { 445 } else if (controller->context()) {
403 GURL origin = controller->script_url().GetOrigin(); 446 GURL origin = controller->script_url().GetOrigin();
404 for (auto it = controller->context()->GetClientProviderHostIterator(origin); 447 for (auto it = controller->context()->GetClientProviderHostIterator(origin);
405 !it->IsAtEnd(); it->Advance()) { 448 !it->IsAtEnd(); it->Advance()) {
406 AddWindowClient(it->GetProviderHost(), &clients_info); 449 AddWindowClient(it->GetProviderHost(), &clients_info);
407 } 450 }
408 } 451 }
409 452
410 if (clients_info.empty()) { 453 if (clients_info.empty()) {
411 DidGetWindowClients(controller, options, callback, 454 DidGetWindowClients(controller, options, callback,
(...skipping 11 matching lines...) Expand all
423 } // namespace 466 } // namespace
424 467
425 void FocusWindowClient(ServiceWorkerProviderHost* provider_host, 468 void FocusWindowClient(ServiceWorkerProviderHost* provider_host,
426 const ClientCallback& callback) { 469 const ClientCallback& callback) {
427 DCHECK_CURRENTLY_ON(BrowserThread::IO); 470 DCHECK_CURRENTLY_ON(BrowserThread::IO);
428 DCHECK_EQ(blink::kWebServiceWorkerClientTypeWindow, 471 DCHECK_EQ(blink::kWebServiceWorkerClientTypeWindow,
429 provider_host->client_type()); 472 provider_host->client_type());
430 BrowserThread::PostTaskAndReplyWithResult( 473 BrowserThread::PostTaskAndReplyWithResult(
431 BrowserThread::UI, FROM_HERE, 474 BrowserThread::UI, FROM_HERE,
432 base::Bind(&FocusOnUI, provider_host->process_id(), 475 base::Bind(&FocusOnUI, provider_host->process_id(),
433 provider_host->frame_id(), provider_host->client_uuid()), 476 provider_host->frame_id(), provider_host->create_time(),
477 provider_host->client_uuid()),
434 callback); 478 callback);
435 } 479 }
436 480
437 void OpenWindow(const GURL& url, 481 void OpenWindow(const GURL& url,
438 const GURL& script_url, 482 const GURL& script_url,
439 int worker_process_id, 483 int worker_process_id,
440 const base::WeakPtr<ServiceWorkerContextCore>& context, 484 const base::WeakPtr<ServiceWorkerContextCore>& context,
441 const NavigationCallback& callback) { 485 const NavigationCallback& callback) {
442 DCHECK_CURRENTLY_ON(BrowserThread::IO); 486 DCHECK_CURRENTLY_ON(BrowserThread::IO);
443 BrowserThread::PostTask( 487 BrowserThread::PostTask(
(...skipping 25 matching lines...) Expand all
469 blink::WebServiceWorkerClientType client_type = provider_host->client_type(); 513 blink::WebServiceWorkerClientType client_type = provider_host->client_type();
470 DCHECK(client_type == blink::kWebServiceWorkerClientTypeWindow || 514 DCHECK(client_type == blink::kWebServiceWorkerClientTypeWindow ||
471 client_type == blink::kWebServiceWorkerClientTypeWorker || 515 client_type == blink::kWebServiceWorkerClientTypeWorker ||
472 client_type == blink::kWebServiceWorkerClientTypeSharedWorker) 516 client_type == blink::kWebServiceWorkerClientTypeSharedWorker)
473 << client_type; 517 << client_type;
474 518
475 if (client_type == blink::kWebServiceWorkerClientTypeWindow) { 519 if (client_type == blink::kWebServiceWorkerClientTypeWindow) {
476 BrowserThread::PostTaskAndReplyWithResult( 520 BrowserThread::PostTaskAndReplyWithResult(
477 BrowserThread::UI, FROM_HERE, 521 BrowserThread::UI, FROM_HERE,
478 base::Bind(&GetWindowClientInfoOnUI, provider_host->process_id(), 522 base::Bind(&GetWindowClientInfoOnUI, provider_host->process_id(),
479 provider_host->route_id(), provider_host->client_uuid()), 523 provider_host->route_id(), provider_host->create_time(),
524 provider_host->client_uuid()),
480 callback); 525 callback);
481 return; 526 return;
482 } 527 }
483 528
484 ServiceWorkerClientInfo client_info( 529 ServiceWorkerClientInfo client_info(
485 provider_host->client_uuid(), blink::kWebPageVisibilityStateHidden, 530 provider_host->client_uuid(), blink::kWebPageVisibilityStateHidden,
486 false, // is_focused 531 false, // is_focused
487 provider_host->document_url(), REQUEST_CONTEXT_FRAME_TYPE_NONE, 532 provider_host->document_url(), REQUEST_CONTEXT_FRAME_TYPE_NONE,
488 base::TimeTicks(), provider_host->client_type()); 533 base::TimeTicks(), provider_host->create_time(),
534 provider_host->client_type());
489 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 535 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
490 base::Bind(callback, client_info)); 536 base::Bind(callback, client_info));
491 } 537 }
492 538
493 void GetClients(const base::WeakPtr<ServiceWorkerVersion>& controller, 539 void GetClients(const base::WeakPtr<ServiceWorkerVersion>& controller,
494 const ServiceWorkerClientQueryOptions& options, 540 const ServiceWorkerClientQueryOptions& options,
495 const ClientsCallback& callback) { 541 const ClientsCallback& callback) {
496 DCHECK_CURRENTLY_ON(BrowserThread::IO); 542 DCHECK_CURRENTLY_ON(BrowserThread::IO);
497 543
498 ServiceWorkerClients clients; 544 ServiceWorkerClients clients;
shimazu 2017/05/25 08:56:26 How about creating std::unique_ptr<ServiceWorkerCl
xiaofengzhang 2017/05/26 04:01:28 Done.
499 if (!controller->HasControllee() && !options.include_uncontrolled) { 545 if (!controller->HasControllee() && !options.include_uncontrolled) {
500 DidGetClients(callback, &clients); 546 DidGetClients(callback, &clients);
501 return; 547 return;
502 } 548 }
503 549
504 // For Window clients we want to query the info on the UI thread first. 550 // For Window clients we want to query the info on the UI thread first.
505 if (options.client_type == blink::kWebServiceWorkerClientTypeWindow || 551 if (options.client_type == blink::kWebServiceWorkerClientTypeWindow ||
506 options.client_type == blink::kWebServiceWorkerClientTypeAll) { 552 options.client_type == blink::kWebServiceWorkerClientTypeAll) {
507 GetWindowClients(controller, options, callback); 553 GetWindowClients(controller, options, callback);
508 return; 554 return;
509 } 555 }
510 556
511 GetNonWindowClients(controller, options, &clients); 557 GetNonWindowClients(controller, options, &clients);
512 DidGetClients(callback, &clients); 558 DidGetClients(callback, &clients);
513 } 559 }
514 560
515 } // namespace service_worker_client_utils 561 } // namespace service_worker_client_utils
516 } // namespace content 562 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_provider_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698