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

Side by Side Diff: device/media_transfer_protocol/media_transfer_protocol_daemon_client.cc

Issue 437313002: Media Galleries: Omit ById in various method names, since all operations are now by id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "device/media_transfer_protocol/media_transfer_protocol_daemon_client.h " 5 #include "device/media_transfer_protocol/media_transfer_protocol_daemon_client.h "
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 144 }
145 proxy_->CallMethod( 145 proxy_->CallMethod(
146 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 146 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
147 base::Bind(&MediaTransferProtocolDaemonClientImpl::OnGetFileInfo, 147 base::Bind(&MediaTransferProtocolDaemonClientImpl::OnGetFileInfo,
148 weak_ptr_factory_.GetWeakPtr(), 148 weak_ptr_factory_.GetWeakPtr(),
149 callback, 149 callback,
150 error_callback)); 150 error_callback));
151 } 151 }
152 152
153 // MediaTransferProtocolDaemonClient override. 153 // MediaTransferProtocolDaemonClient override.
154 virtual void ReadFileChunkById(const std::string& handle, 154 virtual void ReadFileChunk(const std::string& handle,
155 uint32 file_id, 155 uint32 file_id,
156 uint32 offset, 156 uint32 offset,
157 uint32 bytes_to_read, 157 uint32 bytes_to_read,
158 const ReadFileCallback& callback, 158 const ReadFileCallback& callback,
159 const ErrorCallback& error_callback) OVERRIDE { 159 const ErrorCallback& error_callback) OVERRIDE {
160 DCHECK_LE(bytes_to_read, kMaxChunkSize); 160 DCHECK_LE(bytes_to_read, kMaxChunkSize);
161 dbus::MethodCall method_call(mtpd::kMtpdInterface, 161 dbus::MethodCall method_call(mtpd::kMtpdInterface, mtpd::kReadFileChunk);
162 mtpd::kReadFileChunkById);
163 dbus::MessageWriter writer(&method_call); 162 dbus::MessageWriter writer(&method_call);
164 writer.AppendString(handle); 163 writer.AppendString(handle);
165 writer.AppendUint32(file_id); 164 writer.AppendUint32(file_id);
166 writer.AppendUint32(offset); 165 writer.AppendUint32(offset);
167 writer.AppendUint32(bytes_to_read); 166 writer.AppendUint32(bytes_to_read);
168 proxy_->CallMethod( 167 proxy_->CallMethod(
169 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 168 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
170 base::Bind(&MediaTransferProtocolDaemonClientImpl::OnReadFile, 169 base::Bind(&MediaTransferProtocolDaemonClientImpl::OnReadFile,
171 weak_ptr_factory_.GetWeakPtr(), 170 weak_ptr_factory_.GetWeakPtr(),
172 callback, 171 callback,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 LOG(ERROR) << kInvalidResponseMsg << response->ToString(); 323 LOG(ERROR) << kInvalidResponseMsg << response->ToString();
325 error_callback.Run(); 324 error_callback.Run();
326 return; 325 return;
327 } 326 }
328 327
329 for (int i = 0; i < entries_protobuf.file_entries_size(); ++i) 328 for (int i = 0; i < entries_protobuf.file_entries_size(); ++i)
330 file_entries.push_back(entries_protobuf.file_entries(i)); 329 file_entries.push_back(entries_protobuf.file_entries(i));
331 callback.Run(file_entries); 330 callback.Run(file_entries);
332 } 331 }
333 332
334 // Handles the result of ReadFileChunkById and calls |callback| or 333 // Handles the result of ReadFileChunk and calls |callback| or
335 // |error_callback|. 334 // |error_callback|.
336 void OnReadFile(const ReadFileCallback& callback, 335 void OnReadFile(const ReadFileCallback& callback,
337 const ErrorCallback& error_callback, 336 const ErrorCallback& error_callback,
338 dbus::Response* response) { 337 dbus::Response* response) {
339 if (!response) { 338 if (!response) {
340 error_callback.Run(); 339 error_callback.Run();
341 return; 340 return;
342 } 341 }
343 342
344 const uint8* data_bytes = NULL; 343 const uint8* data_bytes = NULL;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 394
396 MediaTransferProtocolDaemonClient::~MediaTransferProtocolDaemonClient() {} 395 MediaTransferProtocolDaemonClient::~MediaTransferProtocolDaemonClient() {}
397 396
398 // static 397 // static
399 MediaTransferProtocolDaemonClient* MediaTransferProtocolDaemonClient::Create( 398 MediaTransferProtocolDaemonClient* MediaTransferProtocolDaemonClient::Create(
400 dbus::Bus* bus) { 399 dbus::Bus* bus) {
401 return new MediaTransferProtocolDaemonClientImpl(bus); 400 return new MediaTransferProtocolDaemonClientImpl(bus);
402 } 401 }
403 402
404 } // namespace device 403 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698