| OLD | NEW |
| 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 Loading... |
| 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. The |web_contents_getter| has been introduced for |
| 376 // getting the WebContents with PlzNavigate without using the |
| 377 // RenderFrameHost. |
| 378 // See https://crbug.com/725818. |
| 376 WebContents* web_contents = | 379 WebContents* web_contents = |
| 377 WebContents::FromRenderFrameHost(render_frame_host); | 380 client.second.web_contents_getter |
| 381 ? client.second.web_contents_getter.Run() |
| 382 : WebContents::FromRenderFrameHost(RenderFrameHostImpl::FromID( |
| 383 client.second.process_id, client.second.route_id)); |
| 378 // There is a possibility that the frame is already deleted | 384 // There is a possibility that the frame is already deleted |
| 379 // because of the thread hopping. | 385 // because of the thread hopping. |
| 380 if (!web_contents) | 386 if (!web_contents) |
| 381 continue; | 387 continue; |
| 382 clients->addItem( | 388 clients->addItem( |
| 383 DevToolsAgentHost::GetOrCreateFor(web_contents)->GetId()); | 389 DevToolsAgentHost::GetOrCreateFor(web_contents)->GetId()); |
| 384 } else if (client.second.type == | 390 } else if (client.second.type == |
| 385 SERVICE_WORKER_PROVIDER_FOR_SHARED_WORKER) { | 391 SERVICE_WORKER_PROVIDER_FOR_SHARED_WORKER) { |
| 386 scoped_refptr<DevToolsAgentHost> agent_host( | 392 scoped_refptr<DevToolsAgentHost> agent_host( |
| 387 DevToolsAgentHost::GetForWorker(client.second.process_id, | 393 DevToolsAgentHost::GetForWorker(client.second.process_id, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 .Build()); | 437 .Build()); |
| 432 } | 438 } |
| 433 | 439 |
| 434 void ServiceWorkerHandler::ClearForceUpdate() { | 440 void ServiceWorkerHandler::ClearForceUpdate() { |
| 435 if (context_) | 441 if (context_) |
| 436 context_->SetForceUpdateOnPageLoad(false); | 442 context_->SetForceUpdateOnPageLoad(false); |
| 437 } | 443 } |
| 438 | 444 |
| 439 } // namespace protocol | 445 } // namespace protocol |
| 440 } // namespace content | 446 } // namespace content |
| OLD | NEW |