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

Side by Side Diff: content/browser/frame_host/navigation_entry_impl.cc

Issue 2191563004: Temporarily dump without crashing when setting an empty PageState. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Allow empty state on new navs. Created 4 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/frame_host/navigation_entry_impl.h" 5 #include "content/browser/frame_host/navigation_entry_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <queue> 9 #include <queue>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/debug/dump_without_crashing.h"
12 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
13 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
14 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
16 #include "build/build_config.h" 17 #include "build/build_config.h"
17 #include "components/url_formatter/url_formatter.h" 18 #include "components/url_formatter/url_formatter.h"
18 #include "content/common/content_constants_internal.h" 19 #include "content/common/content_constants_internal.h"
19 #include "content/common/navigation_params.h" 20 #include "content/common/navigation_params.h"
20 #include "content/common/page_state_serialization.h" 21 #include "content/common/page_state_serialization.h"
21 #include "content/common/resource_request_body_impl.h" 22 #include "content/common/resource_request_body_impl.h"
(...skipping 23 matching lines...) Expand all
45 state.document_sequence_number, nullptr, nullptr, 46 state.document_sequence_number, nullptr, nullptr,
46 GURL(state.url_string.string()), 47 GURL(state.url_string.string()),
47 Referrer(GURL(state.referrer.string()), state.referrer_policy), "GET", 48 Referrer(GURL(state.referrer.string()), state.referrer_policy), "GET",
48 -1); 49 -1);
49 50
50 // Set a single-frame PageState on the entry. 51 // Set a single-frame PageState on the entry.
51 ExplodedPageState page_state; 52 ExplodedPageState page_state;
52 page_state.top = state; 53 page_state.top = state;
53 std::string data; 54 std::string data;
54 EncodePageState(page_state, &data); 55 EncodePageState(page_state, &data);
56 if (data.empty()) {
57 // Temporarily generate a minidump to diagnose https://crbug.com/568703.
58 base::debug::DumpWithoutCrashing();
59 NOTREACHED() << "Shouldn't generate an empty PageState.";
60 }
55 node->frame_entry->set_page_state(PageState::CreateFromEncodedData(data)); 61 node->frame_entry->set_page_state(PageState::CreateFromEncodedData(data));
56 62
57 for (const ExplodedFrameState& child_state : state.children) { 63 for (const ExplodedFrameState& child_state : state.children) {
58 NavigationEntryImpl::TreeNode* child_node = 64 NavigationEntryImpl::TreeNode* child_node =
59 new NavigationEntryImpl::TreeNode(nullptr); 65 new NavigationEntryImpl::TreeNode(nullptr);
60 node->children.push_back(child_node); 66 node->children.push_back(child_node);
61 RecursivelyGenerateFrameEntries(child_state, child_node); 67 RecursivelyGenerateFrameEntries(child_state, child_node);
62 } 68 }
63 } 69 }
64 70
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 // commits. Find it first. 744 // commits. Find it first.
739 DCHECK(frame_tree_node->parent()); 745 DCHECK(frame_tree_node->parent());
740 NavigationEntryImpl::TreeNode* parent_node = 746 NavigationEntryImpl::TreeNode* parent_node =
741 FindFrameEntry(frame_tree_node->parent()); 747 FindFrameEntry(frame_tree_node->parent());
742 if (!parent_node) { 748 if (!parent_node) {
743 // The renderer should not send a commit for a subframe before its parent. 749 // The renderer should not send a commit for a subframe before its parent.
744 // TODO(creis): Kill the renderer if we get here. 750 // TODO(creis): Kill the renderer if we get here.
745 return; 751 return;
746 } 752 }
747 753
754 // We should only have an empty PageState if the navigation is new, and thus
755 // page ID is -1.
756 if (!page_state.IsValid() && GetPageID() != -1) {
757 // Temporarily generate a minidump to diagnose https://crbug.com/568703.
758 base::debug::DumpWithoutCrashing();
759 NOTREACHED() << "Shouldn't set an empty PageState.";
760 }
761
748 // Now check whether we have a TreeNode for the node itself. 762 // Now check whether we have a TreeNode for the node itself.
749 const std::string& unique_name = frame_tree_node->unique_name(); 763 const std::string& unique_name = frame_tree_node->unique_name();
750 for (TreeNode* child : parent_node->children) { 764 for (TreeNode* child : parent_node->children) {
751 if (child->frame_entry->frame_unique_name() == unique_name) { 765 if (child->frame_entry->frame_unique_name() == unique_name) {
752 // If the document of the FrameNavigationEntry is changing, we must clear 766 // If the document of the FrameNavigationEntry is changing, we must clear
753 // any child FrameNavigationEntries. 767 // any child FrameNavigationEntries.
754 if (child->frame_entry->document_sequence_number() != 768 if (child->frame_entry->document_sequence_number() !=
755 document_sequence_number) 769 document_sequence_number)
756 child->children.clear(); 770 child->children.clear();
757 771
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 return node; 825 return node;
812 826
813 // Enqueue any children and keep looking. 827 // Enqueue any children and keep looking.
814 for (auto* child : node->children) 828 for (auto* child : node->children)
815 work_queue.push(child); 829 work_queue.push(child);
816 } 830 }
817 return nullptr; 831 return nullptr;
818 } 832 }
819 833
820 } // namespace content 834 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl.cc ('k') | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698