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

Side by Side Diff: services/ui/view_manager/view_registry.cc

Issue 1759003002: Mozart: Correctly unregister views. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 9 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 // 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 "services/ui/view_manager/view_registry.h" 5 #include "services/ui/view_manager/view_registry.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 else if (view_stub->is_pending()) 452 else if (view_stub->is_pending())
453 CHECK(false); // TODO(jeffbrown): Handle transfer of pending view 453 CHECK(false); // TODO(jeffbrown): Handle transfer of pending view
454 } else { 454 } else {
455 UnregisterViewStub(std::move(view_stub)); 455 UnregisterViewStub(std::move(view_stub));
456 } 456 }
457 } 457 }
458 458
459 void ViewRegistry::UnregisterViewStub(std::unique_ptr<ViewStub> view_stub) { 459 void ViewRegistry::UnregisterViewStub(std::unique_ptr<ViewStub> view_stub) {
460 DCHECK(view_stub); 460 DCHECK(view_stub);
461 461
462 if (view_stub->state()) 462 ViewState* view_state = view_stub->ReleaseView();
463 UnregisterView(view_stub->state()); 463 if (view_state)
464 UnregisterView(view_state);
464 } 465 }
465 466
466 void ViewRegistry::SetLayout(ViewStub* view_stub, 467 void ViewRegistry::SetLayout(ViewStub* view_stub,
467 mojo::ui::ViewLayoutParamsPtr layout_params, 468 mojo::ui::ViewLayoutParamsPtr layout_params,
468 const ViewLayoutCallback& callback) { 469 const ViewLayoutCallback& callback) {
469 DCHECK(view_stub); 470 DCHECK(view_stub);
470 DCHECK(AreViewLayoutParamsValid(layout_params.get())); 471 DCHECK(AreViewLayoutParamsValid(layout_params.get()));
471 472
472 // Immediately discard layout requests on unavailable views. 473 // Immediately discard layout requests on unavailable views.
473 if (view_stub->is_unavailable()) { 474 if (view_stub->is_unavailable()) {
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 DCHECK(IsViewTreeStateRegisteredDebug(tree_state)); 700 DCHECK(IsViewTreeStateRegisteredDebug(tree_state));
700 701
701 // TODO: Detect ANRs 702 // TODO: Detect ANRs
702 DVLOG(1) << "SendRootUnavailable: tree_state=" << tree_state 703 DVLOG(1) << "SendRootUnavailable: tree_state=" << tree_state
703 << ", root_key=" << root_key; 704 << ", root_key=" << root_key;
704 tree_state->view_tree_listener()->OnRootUnavailable( 705 tree_state->view_tree_listener()->OnRootUnavailable(
705 root_key, base::Bind(&base::DoNothing)); 706 root_key, base::Bind(&base::DoNothing));
706 } 707 }
707 708
708 } // namespace view_manager 709 } // namespace view_manager
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