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

Side by Side Diff: mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.cc

Issue 311373005: Nesting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h" 5 #include "mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "mojo/public/cpp/application/connect.h" 9 #include "mojo/public/cpp/application/connect.h"
10 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" 10 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h"
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 virtual void DoActionCompleted(bool success) OVERRIDE { 430 virtual void DoActionCompleted(bool success) OVERRIDE {
431 // TODO(beng): recovery? 431 // TODO(beng): recovery?
432 } 432 }
433 433
434 const String url_; 434 const String url_;
435 const TransportNodeId node_id_; 435 const TransportNodeId node_id_;
436 436
437 DISALLOW_COPY_AND_ASSIGN(EmbedTransaction); 437 DISALLOW_COPY_AND_ASSIGN(EmbedTransaction);
438 }; 438 };
439 439
440 ViewManagerSynchronizer::ViewManagerSynchronizer(ViewManager* view_manager) 440 ViewManagerSynchronizer::ViewManagerSynchronizer(ViewManagerDelegate* delegate)
441 : view_manager_(view_manager), 441 : view_manager_(new ViewManager(this, delegate)),
442 connected_(false), 442 connected_(false),
443 connection_id_(0), 443 connection_id_(0),
444 next_id_(1), 444 next_id_(1),
445 next_server_change_id_(0), 445 next_server_change_id_(0),
446 sync_factory_(this) { 446 sync_factory_(this) {
447 ViewManagerPrivate(view_manager).set_synchronizer(this);
448 } 447 }
449 448
450 ViewManagerSynchronizer::~ViewManagerSynchronizer() { 449 ViewManagerSynchronizer::~ViewManagerSynchronizer() {
451 view_manager_.reset();
452 } 450 }
453 451
454 TransportNodeId ViewManagerSynchronizer::CreateViewTreeNode() { 452 TransportNodeId ViewManagerSynchronizer::CreateViewTreeNode() {
455 DCHECK(connected_); 453 DCHECK(connected_);
456 const TransportNodeId node_id( 454 const TransportNodeId node_id(
457 MakeTransportId(connection_id_, ++next_id_)); 455 MakeTransportId(connection_id_, ++next_id_));
458 pending_transactions_.push_back( 456 pending_transactions_.push_back(
459 new CreateViewTreeNodeTransaction(node_id, this)); 457 new CreateViewTreeNodeTransaction(node_id, this));
460 Sync(); 458 Sync();
461 return node_id; 459 return node_id;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 const Callback<void()>& ack_callback) { 643 const Callback<void()>& ack_callback) {
646 View* view = view_manager_->GetViewById(view_id); 644 View* view = view_manager_->GetViewById(view_id);
647 if (view) { 645 if (view) {
648 FOR_EACH_OBSERVER(ViewObserver, 646 FOR_EACH_OBSERVER(ViewObserver,
649 *ViewPrivate(view).observers(), 647 *ViewPrivate(view).observers(),
650 OnViewInputEvent(view, event.Pass())); 648 OnViewInputEvent(view, event.Pass()));
651 } 649 }
652 ack_callback.Run(); 650 ack_callback.Run();
653 } 651 }
654 652
655
656 //////////////////////////////////////////////////////////////////////////////// 653 ////////////////////////////////////////////////////////////////////////////////
657 // ViewManagerSynchronizer, private: 654 // ViewManagerSynchronizer, private:
658 655
659 void ViewManagerSynchronizer::Sync() { 656 void ViewManagerSynchronizer::Sync() {
660 // The service connection may not be set up yet. OnConnectionEstablished() 657 // The service connection may not be set up yet. OnConnectionEstablished()
661 // will schedule another sync when it is. 658 // will schedule another sync when it is.
662 if (!connected_) 659 if (!connected_)
663 return; 660 return;
664 661
665 Transactions::const_iterator it = pending_transactions_.begin(); 662 Transactions::const_iterator it = pending_transactions_.begin();
666 for (; it != pending_transactions_.end(); ++it) { 663 for (; it != pending_transactions_.end(); ++it) {
667 if (!(*it)->committed()) 664 if (!(*it)->committed())
668 (*it)->Commit(); 665 (*it)->Commit();
669 } 666 }
670 } 667 }
671 668
672 void ViewManagerSynchronizer::RemoveFromPendingQueue( 669 void ViewManagerSynchronizer::RemoveFromPendingQueue(
673 ViewManagerTransaction* transaction) { 670 ViewManagerTransaction* transaction) {
674 DCHECK_EQ(transaction, pending_transactions_.front()); 671 DCHECK_EQ(transaction, pending_transactions_.front());
675 pending_transactions_.erase(pending_transactions_.begin()); 672 pending_transactions_.erase(pending_transactions_.begin());
676 if (pending_transactions_.empty() && !changes_acked_callback_.is_null()) 673 if (pending_transactions_.empty() && !changes_acked_callback_.is_null())
677 changes_acked_callback_.Run(); 674 changes_acked_callback_.Run();
678 } 675 }
679 676
680 } // namespace view_manager 677 } // namespace view_manager
681 } // namespace mojo 678 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698