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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/operations/read_file.cc

Issue 329483002: [fsp] Group arguments for API methods and events in dictionaries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up. 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 "chrome/browser/chromeos/file_system_provider/operations/read_file.h" 5 #include "chrome/browser/chromeos/file_system_provider/operations/read_file.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 9
10 #include "chrome/common/extensions/api/file_system_provider.h" 10 #include "chrome/common/extensions/api/file_system_provider.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 offset_(offset), 55 offset_(offset),
56 length_(length), 56 length_(length),
57 current_offset_(0), 57 current_offset_(0),
58 callback_(callback) { 58 callback_(callback) {
59 } 59 }
60 60
61 ReadFile::~ReadFile() { 61 ReadFile::~ReadFile() {
62 } 62 }
63 63
64 bool ReadFile::Execute(int request_id) { 64 bool ReadFile::Execute(int request_id) {
65 scoped_ptr<base::ListValue> values(new base::ListValue); 65 scoped_ptr<base::DictionaryValue> values(new base::DictionaryValue);
66 values->AppendInteger(file_handle_); 66 values->SetInteger("openRequestId", file_handle_);
67 values->AppendDouble(offset_); 67 values->SetDouble("offset", offset_);
68 values->AppendInteger(length_); 68 values->SetInteger("length", length_);
69 return SendEvent( 69 return SendEvent(
70 request_id, 70 request_id,
71 extensions::api::file_system_provider::OnReadFileRequested::kEventName, 71 extensions::api::file_system_provider::OnReadFileRequested::kEventName,
72 values.Pass()); 72 values.Pass());
73 } 73 }
74 74
75 void ReadFile::OnSuccess(int /* request_id */, 75 void ReadFile::OnSuccess(int /* request_id */,
76 scoped_ptr<RequestValue> result, 76 scoped_ptr<RequestValue> result,
77 bool has_more) { 77 bool has_more) {
78 const int copy_result = CopyRequestValueToBuffer( 78 const int copy_result = CopyRequestValueToBuffer(
79 result.Pass(), buffer_, current_offset_, length_); 79 result.Pass(), buffer_, current_offset_, length_);
80 DCHECK_LE(0, copy_result); 80 DCHECK_LE(0, copy_result);
81 DCHECK(!has_more || copy_result > 0); 81 DCHECK(!has_more || copy_result > 0);
82 if (copy_result > 0) 82 if (copy_result > 0)
83 current_offset_ += copy_result; 83 current_offset_ += copy_result;
84 callback_.Run(copy_result, has_more, base::File::FILE_OK); 84 callback_.Run(copy_result, has_more, base::File::FILE_OK);
85 } 85 }
86 86
87 void ReadFile::OnError(int /* request_id */, base::File::Error error) { 87 void ReadFile::OnError(int /* request_id */, base::File::Error error) {
88 callback_.Run(0 /* chunk_length */, false /* has_more */, error); 88 callback_.Run(0 /* chunk_length */, false /* has_more */, error);
89 } 89 }
90 90
91 } // namespace operations 91 } // namespace operations
92 } // namespace file_system_provider 92 } // namespace file_system_provider
93 } // namespace chromeos 93 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698