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

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: Also catch UpdateEntry 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 // entries exist, but there's currently no way to check that. 328 // entries exist, but there's currently no way to check that.
323 if (!frame_tree_->children.empty()) 329 if (!frame_tree_->children.empty())
324 frame_tree_->children.clear(); 330 frame_tree_->children.clear();
325 331
326 // If the PageState can't be parsed or has no children, just store it on the 332 // If the PageState can't be parsed or has no children, just store it on the
327 // main frame's FrameNavigationEntry without recursively creating subframe 333 // main frame's FrameNavigationEntry without recursively creating subframe
328 // entries. 334 // entries.
329 ExplodedPageState exploded_state; 335 ExplodedPageState exploded_state;
330 if (!DecodePageState(state.ToEncodedData(), &exploded_state) || 336 if (!DecodePageState(state.ToEncodedData(), &exploded_state) ||
331 exploded_state.top.children.size() == 0U) { 337 exploded_state.top.children.size() == 0U) {
332 frame_tree_->frame_entry->set_page_state(state); 338 frame_tree_->frame_entry->set_page_state(state);
Charlie Reis 2016/07/28 21:36:14 I skipped this one because we temporarily set an e
nasko 2016/07/28 21:42:58 Acknowledged.
333 return; 339 return;
334 } 340 }
335 341
336 RecursivelyGenerateFrameEntries(exploded_state.top, frame_tree_.get()); 342 RecursivelyGenerateFrameEntries(exploded_state.top, frame_tree_.get());
337 } 343 }
338 344
339 PageState NavigationEntryImpl::GetPageState() const { 345 PageState NavigationEntryImpl::GetPageState() const {
340 // Just return the main frame's PageState in default Chrome, or if there are 346 // Just return the main frame's PageState in default Chrome, or if there are
341 // no subframe FrameNavigationEntries. 347 // no subframe FrameNavigationEntries.
342 if (!SiteIsolationPolicy::UseSubframeNavigationEntries() || 348 if (!SiteIsolationPolicy::UseSubframeNavigationEntries() ||
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 } 770 }
765 } 771 }
766 772
767 // No entry exists yet, so create a new one. 773 // No entry exists yet, so create a new one.
768 // Unordered list, since we expect to look up entries by frame sequence number 774 // Unordered list, since we expect to look up entries by frame sequence number
769 // or unique name. 775 // or unique name.
770 FrameNavigationEntry* frame_entry = new FrameNavigationEntry( 776 FrameNavigationEntry* frame_entry = new FrameNavigationEntry(
771 unique_name, item_sequence_number, document_sequence_number, 777 unique_name, item_sequence_number, document_sequence_number,
772 site_instance, std::move(source_site_instance), url, referrer, method, 778 site_instance, std::move(source_site_instance), url, referrer, method,
773 post_id); 779 post_id);
780 if (!page_state.IsValid()) {
781 // Temporarily generate a minidump to diagnose https://crbug.com/568703.
782 base::debug::DumpWithoutCrashing();
783 NOTREACHED() << "Shouldn't set an empty PageState.";
784 }
774 frame_entry->set_page_state(page_state); 785 frame_entry->set_page_state(page_state);
775 parent_node->children.push_back( 786 parent_node->children.push_back(
776 new NavigationEntryImpl::TreeNode(frame_entry)); 787 new NavigationEntryImpl::TreeNode(frame_entry));
777 } 788 }
778 789
779 FrameNavigationEntry* NavigationEntryImpl::GetFrameEntry( 790 FrameNavigationEntry* NavigationEntryImpl::GetFrameEntry(
780 FrameTreeNode* frame_tree_node) const { 791 FrameTreeNode* frame_tree_node) const {
781 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node); 792 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node);
782 return tree_node ? tree_node->frame_entry.get() : nullptr; 793 return tree_node ? tree_node->frame_entry.get() : nullptr;
783 } 794 }
(...skipping 27 matching lines...) Expand all
811 return node; 822 return node;
812 823
813 // Enqueue any children and keep looking. 824 // Enqueue any children and keep looking.
814 for (auto* child : node->children) 825 for (auto* child : node->children)
815 work_queue.push(child); 826 work_queue.push(child);
816 } 827 }
817 return nullptr; 828 return nullptr;
818 } 829 }
819 830
820 } // namespace content 831 } // 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