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

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

Issue 2023243002: Remove base::Tuple (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lint fix Created 4 years, 6 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 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 9
9 #include "base/macros.h" 10 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
11 #include "content/browser/frame_host/frame_tree_node.h" 12 #include "content/browser/frame_host/frame_tree_node.h"
12 #include "content/browser/frame_host/render_frame_host_impl.h" 13 #include "content/browser/frame_host/render_frame_host_impl.h"
13 #include "content/browser/service_worker/service_worker_context_core.h" 14 #include "content/browser/service_worker/service_worker_context_core.h"
14 #include "content/browser/service_worker/service_worker_context_wrapper.h" 15 #include "content/browser/service_worker/service_worker_context_wrapper.h"
15 #include "content/browser/service_worker/service_worker_provider_host.h" 16 #include "content/browser/service_worker/service_worker_provider_host.h"
16 #include "content/browser/service_worker/service_worker_version.h" 17 #include "content/browser/service_worker/service_worker_version.h"
17 #include "content/browser/storage_partition_impl.h" 18 #include "content/browser/storage_partition_impl.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 return; 260 return;
260 } 261 }
261 262
262 // If here, it means that no provider_host was found, in which case, the 263 // If here, it means that no provider_host was found, in which case, the
263 // renderer should still be informed that the window was opened. 264 // renderer should still be informed that the window was opened.
264 callback.Run(SERVICE_WORKER_OK, ServiceWorkerClientInfo()); 265 callback.Run(SERVICE_WORKER_OK, ServiceWorkerClientInfo());
265 } 266 }
266 267
267 void AddWindowClient( 268 void AddWindowClient(
268 ServiceWorkerProviderHost* host, 269 ServiceWorkerProviderHost* host,
269 std::vector<base::Tuple<int, int, std::string>>* client_info) { 270 std::vector<std::tuple<int, int, std::string>>* client_info) {
270 DCHECK_CURRENTLY_ON(BrowserThread::IO); 271 DCHECK_CURRENTLY_ON(BrowserThread::IO);
271 if (host->client_type() != blink::WebServiceWorkerClientTypeWindow) 272 if (host->client_type() != blink::WebServiceWorkerClientTypeWindow)
272 return; 273 return;
273 client_info->push_back(base::MakeTuple(host->process_id(), host->frame_id(), 274 client_info->push_back(std::make_tuple(host->process_id(), host->frame_id(),
274 host->client_uuid())); 275 host->client_uuid()));
275 } 276 }
276 277
277 void AddNonWindowClient(ServiceWorkerProviderHost* host, 278 void AddNonWindowClient(ServiceWorkerProviderHost* host,
278 const ServiceWorkerClientQueryOptions& options, 279 const ServiceWorkerClientQueryOptions& options,
279 ServiceWorkerClients* clients) { 280 ServiceWorkerClients* clients) {
280 DCHECK_CURRENTLY_ON(BrowserThread::IO); 281 DCHECK_CURRENTLY_ON(BrowserThread::IO);
281 blink::WebServiceWorkerClientType host_client_type = host->client_type(); 282 blink::WebServiceWorkerClientType host_client_type = host->client_type();
282 if (host_client_type == blink::WebServiceWorkerClientTypeWindow) 283 if (host_client_type == blink::WebServiceWorkerClientTypeWindow)
283 return; 284 return;
284 if (options.client_type != blink::WebServiceWorkerClientTypeAll && 285 if (options.client_type != blink::WebServiceWorkerClientTypeAll &&
285 options.client_type != host_client_type) 286 options.client_type != host_client_type)
286 return; 287 return;
287 288
288 ServiceWorkerClientInfo client_info( 289 ServiceWorkerClientInfo client_info(
289 host->client_uuid(), blink::WebPageVisibilityStateHidden, 290 host->client_uuid(), blink::WebPageVisibilityStateHidden,
290 false, // is_focused 291 false, // is_focused
291 host->document_url(), REQUEST_CONTEXT_FRAME_TYPE_NONE, base::TimeTicks(), 292 host->document_url(), REQUEST_CONTEXT_FRAME_TYPE_NONE, base::TimeTicks(),
292 host_client_type); 293 host_client_type);
293 clients->push_back(client_info); 294 clients->push_back(client_info);
294 } 295 }
295 296
296 void OnGetWindowClientsOnUI( 297 void OnGetWindowClientsOnUI(
297 // The tuple contains process_id, frame_id, client_uuid. 298 // The tuple contains process_id, frame_id, client_uuid.
298 const std::vector<base::Tuple<int, int, std::string>>& clients_info, 299 const std::vector<std::tuple<int, int, std::string>>& clients_info,
299 const GURL& script_url, 300 const GURL& script_url,
300 const GetWindowClientsCallback& callback) { 301 const GetWindowClientsCallback& callback) {
301 DCHECK_CURRENTLY_ON(BrowserThread::UI); 302 DCHECK_CURRENTLY_ON(BrowserThread::UI);
302 303
303 std::unique_ptr<ServiceWorkerClients> clients(new ServiceWorkerClients); 304 std::unique_ptr<ServiceWorkerClients> clients(new ServiceWorkerClients);
304 for (const auto& it : clients_info) { 305 for (const auto& it : clients_info) {
305 ServiceWorkerClientInfo info = GetWindowClientInfoOnUI( 306 ServiceWorkerClientInfo info = GetWindowClientInfoOnUI(
306 base::get<0>(it), base::get<1>(it), base::get<2>(it)); 307 std::get<0>(it), std::get<1>(it), std::get<2>(it));
307 308
308 // If the request to the provider_host returned an empty 309 // If the request to the provider_host returned an empty
309 // ServiceWorkerClientInfo, that means that it wasn't possible to associate 310 // ServiceWorkerClientInfo, that means that it wasn't possible to associate
310 // it with a valid RenderFrameHost. It might be because the frame was killed 311 // it with a valid RenderFrameHost. It might be because the frame was killed
311 // or navigated in between. 312 // or navigated in between.
312 if (info.IsEmpty()) 313 if (info.IsEmpty())
313 continue; 314 continue;
314 315
315 // We can get info for a frame that was navigating end ended up with a 316 // We can get info for a frame that was navigating end ended up with a
316 // different URL than expected. In such case, we should make sure to not 317 // different URL than expected. In such case, we should make sure to not
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 DidGetClients(callback, clients.get()); 369 DidGetClients(callback, clients.get());
369 } 370 }
370 371
371 void GetWindowClients(const base::WeakPtr<ServiceWorkerVersion>& controller, 372 void GetWindowClients(const base::WeakPtr<ServiceWorkerVersion>& controller,
372 const ServiceWorkerClientQueryOptions& options, 373 const ServiceWorkerClientQueryOptions& options,
373 const ClientsCallback& callback) { 374 const ClientsCallback& callback) {
374 DCHECK_CURRENTLY_ON(BrowserThread::IO); 375 DCHECK_CURRENTLY_ON(BrowserThread::IO);
375 DCHECK(options.client_type == blink::WebServiceWorkerClientTypeWindow || 376 DCHECK(options.client_type == blink::WebServiceWorkerClientTypeWindow ||
376 options.client_type == blink::WebServiceWorkerClientTypeAll); 377 options.client_type == blink::WebServiceWorkerClientTypeAll);
377 378
378 std::vector<base::Tuple<int, int, std::string>> clients_info; 379 std::vector<std::tuple<int, int, std::string>> clients_info;
379 if (!options.include_uncontrolled) { 380 if (!options.include_uncontrolled) {
380 for (auto& controllee : controller->controllee_map()) 381 for (auto& controllee : controller->controllee_map())
381 AddWindowClient(controllee.second, &clients_info); 382 AddWindowClient(controllee.second, &clients_info);
382 } else if (controller->context()) { 383 } else if (controller->context()) {
383 GURL origin = controller->script_url().GetOrigin(); 384 GURL origin = controller->script_url().GetOrigin();
384 for (auto it = controller->context()->GetClientProviderHostIterator(origin); 385 for (auto it = controller->context()->GetClientProviderHostIterator(origin);
385 !it->IsAtEnd(); it->Advance()) { 386 !it->IsAtEnd(); it->Advance()) {
386 AddWindowClient(it->GetProviderHost(), &clients_info); 387 AddWindowClient(it->GetProviderHost(), &clients_info);
387 } 388 }
388 } 389 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 GetWindowClients(controller, options, callback); 488 GetWindowClients(controller, options, callback);
488 return; 489 return;
489 } 490 }
490 491
491 GetNonWindowClients(controller, options, &clients); 492 GetNonWindowClients(controller, options, &clients);
492 DidGetClients(callback, &clients); 493 DidGetClients(callback, &clients);
493 } 494 }
494 495
495 } // namespace service_worker_client_utils 496 } // namespace service_worker_client_utils
496 } // namespace content 497 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/resolve_proxy_msg_helper_unittest.cc ('k') | content/browser/service_worker/service_worker_handle_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698