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

Side by Side Diff: third_party/WebKit/Source/core/page/FrameTree.cpp

Issue 2078643002: More aggressive DCHECKs for FrameTree::setName. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
3 * Copyright (C) 2006 Apple Computer, Inc. 3 * Copyright (C) 2006 Apple Computer, Inc.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 , m_scopedChildCount(invalidChildCount) 47 , m_scopedChildCount(invalidChildCount)
48 { 48 {
49 } 49 }
50 50
51 FrameTree::~FrameTree() 51 FrameTree::~FrameTree()
52 { 52 {
53 } 53 }
54 54
55 void FrameTree::setName(const AtomicString& name) 55 void FrameTree::setName(const AtomicString& name)
56 { 56 {
57 // This method should only be called for local frames
58 // (remote frames should be updated via setPrecalculatedName).
59 DCHECK(m_thisFrame->isLocalFrame());
60
61 // When this method is called, m_uniqueName should be already initialized.
62 // This assert helps ensure that early return (a few lines below) won't
63 // result in an uninitialized m_uniqueName.
64 DCHECK(!m_uniqueName.isNull()
65 || (m_uniqueName.isNull() && m_name.isNull() && !parent()));
Łukasz Anforowicz 2016/06/16 22:11:38 I think it is important to move this DCHECK out of
66
57 // Do not recalculate m_uniqueName if there is no real change of m_name. 67 // Do not recalculate m_uniqueName if there is no real change of m_name.
58 // This is not just a performance optimization - other code relies on the 68 // This is not just a performance optimization - other code relies on the
59 // assumption that unique name shouldn't change if the assigned name didn't 69 // assumption that unique name shouldn't change if the assigned name didn't
60 // change (i.e. code in content::FrameTreeNode::SetFrameName). 70 // change (i.e. code in content::FrameTreeNode::SetFrameName).
61 if (m_name == name) { 71 if (m_name == name)
62 // Assert that returning early below won't leave m_uniqueName in an
63 // uninitialized state - it should only be null if m_name is also
64 // null and only if it is for the main frame.
65 // m_uniqueName.isNull() should imply m_name.isNull() && !parent().
66 // this FrameTree is for a main frame.
67 DCHECK(!m_uniqueName.isNull() || (m_name.isNull() && !parent()));
68 return; 72 return;
69 }
70 73
71 m_name = name; 74 m_name = name;
72 75
73 // Remove our old frame name so it's not considered in calculateUniqueNameFo rChildFrame 76 // Remove our old frame name so it's not considered in calculateUniqueNameFo rChildFrame
74 // and appendUniqueSuffix calls below. 77 // and appendUniqueSuffix calls below.
75 m_uniqueName = AtomicString(); 78 m_uniqueName = AtomicString();
76 79
77 // Calculate a new unique name based on inputs. 80 // Calculate a new unique name based on inputs.
78 if (parent()) { 81 if (parent()) {
79 setUniqueName( 82 setUniqueName(
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 { 594 {
592 if (!frame) { 595 if (!frame) {
593 printf("Null input frame\n"); 596 printf("Null input frame\n");
594 return; 597 return;
595 } 598 }
596 599
597 printFrames(frame->tree().top(), frame, 0); 600 printFrames(frame->tree().top(), frame, 0);
598 } 601 }
599 602
600 #endif 603 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698