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

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

Issue 383293002: Start of adding enums for error codes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | « no previous file | mojo/services/public/interfaces/view_manager/view_manager.mojom » ('j') | 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/public/cpp/view_manager/lib/view_manager_client_impl.h" 5 #include "mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.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/application_connection.h" 9 #include "mojo/public/cpp/application/application_connection.h"
10 #include "mojo/public/cpp/application/connect.h" 10 #include "mojo/public/cpp/application/connect.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // Overridden to perform transaction-specific cleanup on commit ack from the 130 // Overridden to perform transaction-specific cleanup on commit ack from the
131 // service. 131 // service.
132 virtual void DoActionCompleted(bool success) = 0; 132 virtual void DoActionCompleted(bool success) = 0;
133 133
134 ViewManagerService* service() { return client_->service_; } 134 ViewManagerService* service() { return client_->service_; }
135 135
136 Id GetAndAdvanceNextServerChangeId() { 136 Id GetAndAdvanceNextServerChangeId() {
137 return client_->next_server_change_id_++; 137 return client_->next_server_change_id_++;
138 } 138 }
139 139
140 // TODO(sky): nuke this and covert all to new one, then rename
141 // ActionCompletedCallbackWithErrorCode to ActionCompletedCallback.
140 base::Callback<void(bool)> ActionCompletedCallback() { 142 base::Callback<void(bool)> ActionCompletedCallback() {
141 return base::Bind(&ViewManagerTransaction::OnActionCompleted, 143 return base::Bind(&ViewManagerTransaction::OnActionCompleted,
142 base::Unretained(this)); 144 base::Unretained(this));
143 } 145 }
144 146
147 base::Callback<void(ErrorCode)> ActionCompletedCallbackWithErrorCode() {
148 return base::Bind(&ViewManagerTransaction::OnActionCompletedWithErrorCode,
149 base::Unretained(this));
150 }
151
145 private: 152 private:
146 // General callback to be used for commits to the service. 153 // General callback to be used for commits to the service.
147 void OnActionCompleted(bool success) { 154 void OnActionCompleted(bool success) {
148 DoActionCompleted(success); 155 DoActionCompleted(success);
149 client_->RemoveFromPendingQueue(this); 156 client_->RemoveFromPendingQueue(this);
150 } 157 }
151 158
159 void OnActionCompletedWithErrorCode(ErrorCode error_code) {
160 DoActionCompleted(error_code == ERROR_CODE_NONE);
161 client_->RemoveFromPendingQueue(this);
162 }
163
152 bool committed_; 164 bool committed_;
153 ViewManagerClientImpl* client_; 165 ViewManagerClientImpl* client_;
154 166
155 DISALLOW_COPY_AND_ASSIGN(ViewManagerTransaction); 167 DISALLOW_COPY_AND_ASSIGN(ViewManagerTransaction);
156 }; 168 };
157 169
158 class CreateViewTransaction : public ViewManagerTransaction { 170 class CreateViewTransaction : public ViewManagerTransaction {
159 public: 171 public:
160 CreateViewTransaction(Id view_id, ViewManagerClientImpl* client) 172 CreateViewTransaction(Id view_id, ViewManagerClientImpl* client)
161 : ViewManagerTransaction(client), 173 : ViewManagerTransaction(client),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 class CreateNodeTransaction : public ViewManagerTransaction { 214 class CreateNodeTransaction : public ViewManagerTransaction {
203 public: 215 public:
204 CreateNodeTransaction(Id node_id, ViewManagerClientImpl* client) 216 CreateNodeTransaction(Id node_id, ViewManagerClientImpl* client)
205 : ViewManagerTransaction(client), 217 : ViewManagerTransaction(client),
206 node_id_(node_id) {} 218 node_id_(node_id) {}
207 virtual ~CreateNodeTransaction() {} 219 virtual ~CreateNodeTransaction() {}
208 220
209 private: 221 private:
210 // Overridden from ViewManagerTransaction: 222 // Overridden from ViewManagerTransaction:
211 virtual void DoCommit() OVERRIDE { 223 virtual void DoCommit() OVERRIDE {
212 service()->CreateNode(node_id_, ActionCompletedCallback()); 224 service()->CreateNode(node_id_, ActionCompletedCallbackWithErrorCode());
213 } 225 }
214 virtual void DoActionCompleted(bool success) OVERRIDE { 226 virtual void DoActionCompleted(bool success) OVERRIDE {
215 // TODO(beng): Failure means we tried to create with an extant id for this 227 // TODO(beng): Failure means we tried to create with an extant id for this
216 // connection. It also could mean we tried to do something 228 // connection. It also could mean we tried to do something
217 // invalid, or we tried applying a change out of order. Figure 229 // invalid, or we tried applying a change out of order. Figure
218 // out what to do. 230 // out what to do.
219 DCHECK(success); 231 DCHECK(success);
220 } 232 }
221 233
222 const Id node_id_; 234 const Id node_id_;
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 910
899 // static 911 // static
900 void ViewManager::ConfigureIncomingConnection( 912 void ViewManager::ConfigureIncomingConnection(
901 ApplicationConnection* connection, 913 ApplicationConnection* connection,
902 ViewManagerDelegate* delegate) { 914 ViewManagerDelegate* delegate) {
903 connection->AddService<ViewManagerClientImpl>(delegate); 915 connection->AddService<ViewManagerClientImpl>(delegate);
904 } 916 }
905 917
906 } // namespace view_manager 918 } // namespace view_manager
907 } // namespace mojo 919 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/services/public/interfaces/view_manager/view_manager.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698