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

Side by Side Diff: content/browser/devtools/protocol/service_worker_handler.cc

Issue 2917643002: PlzNavigate: Fix ServiceWorkerHandler not finding WebContents. (Closed)
Patch Set: Shorter comment. Created 3 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
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_context_core.cc » ('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/devtools/protocol/service_worker_handler.h" 5 #include "content/browser/devtools/protocol/service_worker_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/browser/background_sync/background_sync_context.h" 10 #include "content/browser/background_sync/background_sync_context.h"
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 void ServiceWorkerHandler::OnWorkerVersionUpdated( 364 void ServiceWorkerHandler::OnWorkerVersionUpdated(
365 const std::vector<ServiceWorkerVersionInfo>& versions) { 365 const std::vector<ServiceWorkerVersionInfo>& versions) {
366 using Version = ServiceWorker::ServiceWorkerVersion; 366 using Version = ServiceWorker::ServiceWorkerVersion;
367 std::unique_ptr<protocol::Array<Version>> result = 367 std::unique_ptr<protocol::Array<Version>> result =
368 protocol::Array<Version>::create(); 368 protocol::Array<Version>::create();
369 for (const auto& version : versions) { 369 for (const auto& version : versions) {
370 std::unique_ptr<protocol::Array<std::string>> clients = 370 std::unique_ptr<protocol::Array<std::string>> clients =
371 protocol::Array<std::string>::create(); 371 protocol::Array<std::string>::create();
372 for (const auto& client : version.clients) { 372 for (const auto& client : version.clients) {
373 if (client.second.type == SERVICE_WORKER_PROVIDER_FOR_WINDOW) { 373 if (client.second.type == SERVICE_WORKER_PROVIDER_FOR_WINDOW) {
374 RenderFrameHostImpl* render_frame_host = RenderFrameHostImpl::FromID( 374 // PlzNavigate: a navigation may not yet be associated with a
375 client.second.process_id, client.second.route_id); 375 // RenderFrameHost. Use the |web_contents_getter| instead.
376 WebContents* web_contents = 376 WebContents* web_contents =
377 WebContents::FromRenderFrameHost(render_frame_host); 377 client.second.web_contents_getter
378 ? client.second.web_contents_getter.Run()
379 : WebContents::FromRenderFrameHost(RenderFrameHostImpl::FromID(
380 client.second.process_id, client.second.route_id));
378 // There is a possibility that the frame is already deleted 381 // There is a possibility that the frame is already deleted
379 // because of the thread hopping. 382 // because of the thread hopping.
380 if (!web_contents) 383 if (!web_contents)
381 continue; 384 continue;
382 clients->addItem( 385 clients->addItem(
383 DevToolsAgentHost::GetOrCreateFor(web_contents)->GetId()); 386 DevToolsAgentHost::GetOrCreateFor(web_contents)->GetId());
384 } else if (client.second.type == 387 } else if (client.second.type ==
385 SERVICE_WORKER_PROVIDER_FOR_SHARED_WORKER) { 388 SERVICE_WORKER_PROVIDER_FOR_SHARED_WORKER) {
386 scoped_refptr<DevToolsAgentHost> agent_host( 389 scoped_refptr<DevToolsAgentHost> agent_host(
387 DevToolsAgentHost::GetForWorker(client.second.process_id, 390 DevToolsAgentHost::GetForWorker(client.second.process_id,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 .Build()); 434 .Build());
432 } 435 }
433 436
434 void ServiceWorkerHandler::ClearForceUpdate() { 437 void ServiceWorkerHandler::ClearForceUpdate() {
435 if (context_) 438 if (context_)
436 context_->SetForceUpdateOnPageLoad(false); 439 context_->SetForceUpdateOnPageLoad(false);
437 } 440 }
438 441
439 } // namespace protocol 442 } // namespace protocol
440 } // namespace content 443 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_context_core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698