OLD | NEW |
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 "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 offset_(offset), | 56 offset_(offset), |
57 length_(length), | 57 length_(length), |
58 current_offset_(0), | 58 current_offset_(0), |
59 callback_(callback) { | 59 callback_(callback) { |
60 } | 60 } |
61 | 61 |
62 ReadFile::~ReadFile() { | 62 ReadFile::~ReadFile() { |
63 } | 63 } |
64 | 64 |
65 bool ReadFile::Execute(int request_id) { | 65 bool ReadFile::Execute(int request_id) { |
| 66 using extensions::api::file_system_provider::ReadFileRequestedOptions; |
66 TRACE_EVENT0("file_system_provider", "ReadFile::Execute"); | 67 TRACE_EVENT0("file_system_provider", "ReadFile::Execute"); |
67 scoped_ptr<base::DictionaryValue> values(new base::DictionaryValue); | 68 |
68 values->SetInteger("openRequestId", file_handle_); | 69 ReadFileRequestedOptions options; |
69 values->SetDouble("offset", offset_); | 70 options.file_system_id = file_system_info_.file_system_id(); |
70 values->SetInteger("length", length_); | 71 options.request_id = request_id; |
| 72 options.open_request_id = file_handle_; |
| 73 options.offset = offset_; |
| 74 options.length = length_; |
| 75 |
71 return SendEvent( | 76 return SendEvent( |
72 request_id, | 77 request_id, |
73 extensions::api::file_system_provider::OnReadFileRequested::kEventName, | 78 extensions::api::file_system_provider::OnReadFileRequested::kEventName, |
74 values.Pass()); | 79 extensions::api::file_system_provider::OnReadFileRequested::Create( |
| 80 options)); |
75 } | 81 } |
76 | 82 |
77 void ReadFile::OnSuccess(int /* request_id */, | 83 void ReadFile::OnSuccess(int /* request_id */, |
78 scoped_ptr<RequestValue> result, | 84 scoped_ptr<RequestValue> result, |
79 bool has_more) { | 85 bool has_more) { |
80 TRACE_EVENT0("file_system_provider", "ReadFile::OnSuccess"); | 86 TRACE_EVENT0("file_system_provider", "ReadFile::OnSuccess"); |
81 const int copy_result = CopyRequestValueToBuffer( | 87 const int copy_result = CopyRequestValueToBuffer( |
82 result.Pass(), buffer_, current_offset_, length_); | 88 result.Pass(), buffer_, current_offset_, length_); |
83 | 89 |
84 if (copy_result < 0) { | 90 if (copy_result < 0) { |
(...skipping 11 matching lines...) Expand all Loading... |
96 void ReadFile::OnError(int /* request_id */, | 102 void ReadFile::OnError(int /* request_id */, |
97 scoped_ptr<RequestValue> /* result */, | 103 scoped_ptr<RequestValue> /* result */, |
98 base::File::Error error) { | 104 base::File::Error error) { |
99 TRACE_EVENT0("file_system_provider", "ReadFile::OnError"); | 105 TRACE_EVENT0("file_system_provider", "ReadFile::OnError"); |
100 callback_.Run(0 /* chunk_length */, false /* has_more */, error); | 106 callback_.Run(0 /* chunk_length */, false /* has_more */, error); |
101 } | 107 } |
102 | 108 |
103 } // namespace operations | 109 } // namespace operations |
104 } // namespace file_system_provider | 110 } // namespace file_system_provider |
105 } // namespace chromeos | 111 } // namespace chromeos |
OLD | NEW |