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

Unified Diff: content/browser/frame_host/navigation_request.cc

Issue 2501343003: PlzNavigate: AppCache support. (Closed)
Patch Set: Add DCHECKs for PlzNavigate and fix a double Release problem which caused one unit_test to fail wit… Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/navigation_request.cc
diff --git a/content/browser/frame_host/navigation_request.cc b/content/browser/frame_host/navigation_request.cc
index 8feb8e20b4703844c6e6de8b98378b9c01a30f04..6fb76918e43b3fe5a90079c39bb60c0c656d2a82 100644
--- a/content/browser/frame_host/navigation_request.cc
+++ b/content/browser/frame_host/navigation_request.cc
@@ -6,6 +6,8 @@
#include <utility>
+#include "content/browser/appcache/appcache_frame_node_navigation.h"
+#include "content/browser/appcache/appcache_service_impl.h"
#include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/devtools/render_frame_devtools_agent_host.h"
#include "content/browser/frame_host/frame_tree.h"
@@ -28,6 +30,7 @@
#include "content/public/browser/navigation_ui_data.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/stream_handle.h"
+#include "content/public/common/appcache_info.h"
#include "content/public/common/content_client.h"
#include "content/public/common/request_context_type.h"
#include "content/public/common/resource_response.h"
@@ -222,7 +225,9 @@ NavigationRequest::NavigationRequest(
restore_type_(RestoreType::NONE),
is_view_source_(false),
bindings_(NavigationEntryImpl::kInvalidBindings),
- associated_site_instance_type_(AssociatedSiteInstanceType::NONE) {
+ associated_site_instance_type_(AssociatedSiteInstanceType::NONE),
+ appcache_host_id_(kAppCacheNoHostId),
+ navigation_committed_(false) {
DCHECK(!browser_initiated || (entry != nullptr && frame_entry != nullptr));
if (browser_initiated) {
FrameNavigationEntry* frame_entry = entry->GetFrameEntry(frame_tree_node);
@@ -256,6 +261,13 @@ NavigationRequest::NavigationRequest(
}
NavigationRequest::~NavigationRequest() {
+ // If the navigation was started but never committed we need to inform the
+ // AppCacheFrameNavigationHandler about this so it can clean up any state.
+ if ((state_ == STARTED || state_ == RESPONSE_STARTED) &&
+ !navigation_committed_) {
+ AppCacheFrameNavigationHandler::FailedNavigation(
+ frame_tree_node_->frame_tree_node_id());
+ }
}
void NavigationRequest::BeginNavigation() {
@@ -264,6 +276,18 @@ void NavigationRequest::BeginNavigation() {
state_ = STARTED;
RenderFrameDevToolsAgentHost::OnBeforeNavigation(navigation_handle_.get());
+ SiteInstance* site_instance =
+ frame_tree_node_->current_frame_host()->GetSiteInstance();
+ StoragePartition* partition = BrowserContext::GetStoragePartition(
+ site_instance->GetBrowserContext(), site_instance);
+
+ // Inform the AppCacheFrameNavigationHandler class about this navigation.
+ // This function returns the AppCache host id which we need to pass to the
+ // renderer when the navigation commits.
+ appcache_host_id_ = AppCacheFrameNavigationHandler::BeginNavigation(
+ static_cast<AppCacheServiceImpl*>(partition->GetAppCacheService()),
+ frame_tree_node_->frame_tree_node_id());
+
if (ShouldMakeNetworkRequestForURL(common_params_.url)) {
// It's safe to use base::Unretained because this NavigationRequest owns
// the NavigationHandle where the callback will be stored.
@@ -436,6 +460,10 @@ void NavigationRequest::OnRequestFailed(bool has_stale_copy_in_cache,
int net_error) {
DCHECK(state_ == STARTED);
state_ = FAILED;
+
+ AppCacheFrameNavigationHandler::FailedNavigation(
+ frame_tree_node_->frame_tree_node_id());
+
navigation_handle_->set_net_error_code(static_cast<net::Error>(net_error));
frame_tree_node_->navigator()->FailedNavigation(
frame_tree_node_, has_stale_copy_in_cache, net_error);
@@ -531,7 +559,8 @@ void NavigationRequest::OnStartChecksComplete(
frame_tree_node_->current_origin(), frame_tree_node_->IsMainFrame(),
parent_is_main_frame, IsSecureFrame(frame_tree_node_->parent()),
frame_tree_node_->frame_tree_node_id(), is_for_guests_only,
- report_raw_headers),
+ report_raw_headers, appcache_host_id_,
+ static_cast<AppCacheServiceImpl*>(partition->GetAppCacheService())),
std::move(navigation_ui_data),
navigation_handle_->service_worker_handle(), this);
}
@@ -588,6 +617,14 @@ void NavigationRequest::CommitNavigation() {
DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture);
+ AppCacheFrameNavigationHandler::CommitNavigation(
+ frame_tree_node_->frame_tree_node_id(),
+ render_frame_host->GetProcess()->GetID());
+
+ navigation_committed_ = true;
+
+ request_params_.appcache_host_id = appcache_host_id_;
+
render_frame_host->CommitNavigation(response_.get(), std::move(body_),
common_params_, request_params_,
is_view_source_);

Powered by Google App Engine
This is Rietveld 408576698