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

Side by Side Diff: mandoline/tab/frame.cc

Issue 1153393007: Fix assert on Mandoline shutdown. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 5 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 | « mandoline/tab/frame.h ('k') | 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 // 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 "mandoline/tab/frame.h" 5 #include "mandoline/tab/frame.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "components/view_manager/public/cpp/view.h" 10 #include "components/view_manager/public/cpp/view.h"
(...skipping 25 matching lines...) Expand all
36 *services = GetProxy(&services_).Pass(); 36 *services = GetProxy(&services_).Pass();
37 37
38 if (exposed_services) { 38 if (exposed_services) {
39 mojo::ServiceProviderPtr exposed_services_ptr; 39 mojo::ServiceProviderPtr exposed_services_ptr;
40 exposed_services_.Bind(GetProxy(&exposed_services_ptr)); 40 exposed_services_.Bind(GetProxy(&exposed_services_ptr));
41 *exposed_services = exposed_services_ptr.Pass(); 41 *exposed_services = exposed_services_ptr.Pass();
42 } 42 }
43 } 43 }
44 44
45 Frame::~Frame() { 45 Frame::~Frame() {
46 view_->RemoveObserver(this); 46 if (view_)
47 view_->RemoveObserver(this);
47 STLDeleteElements(&children_); 48 STLDeleteElements(&children_);
48 if (parent_) 49 if (parent_)
49 parent_->Remove(this); 50 parent_->Remove(this);
50 view_->ClearLocalProperty(kFrame); 51 if (view_)
52 view_->ClearLocalProperty(kFrame);
51 if (view_ownership_ == ViewOwnership::OWNS_VIEW) 53 if (view_ownership_ == ViewOwnership::OWNS_VIEW)
52 view_->Destroy(); 54 view_->Destroy();
53 } 55 }
54 56
55 // static 57 // static
56 Frame* Frame::FindFirstFrameAncestor(View* view) { 58 Frame* Frame::FindFirstFrameAncestor(View* view) {
57 while (view && !view->GetLocalProperty(kFrame)) 59 while (view && !view->GetLocalProperty(kFrame))
58 view = view->parent(); 60 view = view->parent();
59 return view ? view->GetLocalProperty(kFrame) : nullptr; 61 return view ? view->GetLocalProperty(kFrame) : nullptr;
60 } 62 }
(...skipping 10 matching lines...) Expand all
71 DCHECK_EQ(node->parent_, this); 73 DCHECK_EQ(node->parent_, this);
72 auto iter = std::find(children_.begin(), children_.end(), node); 74 auto iter = std::find(children_.begin(), children_.end(), node);
73 DCHECK(iter != children_.end()); 75 DCHECK(iter != children_.end());
74 node->parent_ = nullptr; 76 node->parent_ = nullptr;
75 children_.erase(iter); 77 children_.erase(iter);
76 } 78 }
77 79
78 void Frame::OnViewDestroying(mojo::View* view) { 80 void Frame::OnViewDestroying(mojo::View* view) {
79 if (parent_) 81 if (parent_)
80 parent_->Remove(this); 82 parent_->Remove(this);
81 // Assume the view associated with the root is never deleted out from under
82 // us.
83 // TODO(sky): this is likely bogus. Change browser to create a child for
84 // each FrameTree.
85 DCHECK_NE(this, tree_->root());
86 83
87 // Reset |view_ownership_| so we don't attempt to delete |view_| in the 84 // Reset |view_ownership_| so we don't attempt to delete |view_| in the
88 // destructor. 85 // destructor.
89 view_ownership_ = ViewOwnership::DOESNT_OWN_VIEW; 86 view_ownership_ = ViewOwnership::DOESNT_OWN_VIEW;
87
88 // Assume the view associated with the root is never deleted out from under
89 // us.
90 // TODO(sky): Change browser to create a child for each FrameTree.
91 if (tree_->root() == this) {
92 view_->RemoveObserver(this);
93 view_ = nullptr;
94 return;
95 }
96
90 delete this; 97 delete this;
91 } 98 }
92 99
93 } // namespace mandoline 100 } // namespace mandoline
OLDNEW
« no previous file with comments | « mandoline/tab/frame.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698