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

Side by Side Diff: mojo/services/view_manager/view_manager_connection.cc

Issue 292813008: Implement SetViewContents in the client lib (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
« no previous file with comments | « mojo/services/view_manager/view_manager_connection.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 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/view_manager/view_manager_connection.h" 5 #include "mojo/services/view_manager/view_manager_connection.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "mojo/geometry/geometry_type_converters.h" 8 #include "mojo/geometry/geometry_type_converters.h"
9 #include "mojo/public/cpp/bindings/allocation_scope.h" 9 #include "mojo/public/cpp/bindings/allocation_scope.h"
10 #include "mojo/services/view_manager/node.h" 10 #include "mojo/services/view_manager/node.h"
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 TransportViewId transport_view_id, 564 TransportViewId transport_view_id,
565 const Callback<void(bool)>& callback) { 565 const Callback<void(bool)>& callback) {
566 Node* node = GetNode(NodeIdFromTransportId(transport_node_id)); 566 Node* node = GetNode(NodeIdFromTransportId(transport_node_id));
567 const ViewId view_id(ViewIdFromTransportId(transport_view_id)); 567 const ViewId view_id(ViewIdFromTransportId(transport_view_id));
568 callback.Run(CanSetView(node, view_id) && SetViewImpl(node, view_id)); 568 callback.Run(CanSetView(node, view_id) && SetViewImpl(node, view_id));
569 } 569 }
570 570
571 void ViewManagerConnection::SetViewContents( 571 void ViewManagerConnection::SetViewContents(
572 TransportViewId view_id, 572 TransportViewId view_id,
573 ScopedSharedBufferHandle buffer, 573 ScopedSharedBufferHandle buffer,
574 uint32_t buffer_size) { 574 uint32_t buffer_size,
575 const Callback<void(bool)>& callback) {
575 View* view = GetView(ViewIdFromTransportId(view_id)); 576 View* view = GetView(ViewIdFromTransportId(view_id));
576 if (!view) 577 if (!view) {
578 callback.Run(false);
577 return; 579 return;
580 }
578 void* handle_data; 581 void* handle_data;
579 if (MapBuffer(buffer.get(), 0, buffer_size, &handle_data, 582 if (MapBuffer(buffer.get(), 0, buffer_size, &handle_data,
580 MOJO_MAP_BUFFER_FLAG_NONE) != MOJO_RESULT_OK) { 583 MOJO_MAP_BUFFER_FLAG_NONE) != MOJO_RESULT_OK) {
584 callback.Run(false);
581 return; 585 return;
582 } 586 }
583 SkBitmap bitmap; 587 SkBitmap bitmap;
584 gfx::PNGCodec::Decode(static_cast<const unsigned char*>(handle_data), 588 gfx::PNGCodec::Decode(static_cast<const unsigned char*>(handle_data),
585 buffer_size, &bitmap); 589 buffer_size, &bitmap);
586 view->SetBitmap(bitmap); 590 view->SetBitmap(bitmap);
587 UnmapBuffer(handle_data); 591 UnmapBuffer(handle_data);
592 callback.Run(true);
588 } 593 }
589 594
590 void ViewManagerConnection::SetRoots( 595 void ViewManagerConnection::SetRoots(
591 TransportConnectionId connection_id, 596 TransportConnectionId connection_id,
592 const Array<TransportNodeId>& transport_node_ids, 597 const Array<TransportNodeId>& transport_node_ids,
593 const Callback<void(bool)>& callback) { 598 const Callback<void(bool)>& callback) {
594 ViewManagerConnection* connection = 599 ViewManagerConnection* connection =
595 root_node_manager_->GetConnection(connection_id); 600 root_node_manager_->GetConnection(connection_id);
596 callback.Run(connection && 601 callback.Run(connection &&
597 connection->ProcessSetRoots(id_, transport_node_ids)); 602 connection->ProcessSetRoots(id_, transport_node_ids));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 634
630 void ViewManagerConnection::OnNodeViewReplaced(const Node* node, 635 void ViewManagerConnection::OnNodeViewReplaced(const Node* node,
631 const View* new_view, 636 const View* new_view,
632 const View* old_view) { 637 const View* old_view) {
633 root_node_manager_->ProcessNodeViewReplaced(node, new_view, old_view); 638 root_node_manager_->ProcessNodeViewReplaced(node, new_view, old_view);
634 } 639 }
635 640
636 } // namespace service 641 } // namespace service
637 } // namespace view_manager 642 } // namespace view_manager
638 } // namespace mojo 643 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/view_manager/view_manager_connection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698