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 <memory> |
7 #include <string> | 8 #include <string> |
8 #include <utility> | 9 #include <utility> |
9 | 10 |
10 #include "base/files/file.h" | 11 #include "base/files/file.h" |
11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "chrome/browser/chromeos/file_system_provider/operations/test_util.h" | 17 #include "chrome/browser/chromeos/file_system_provider/operations/test_util.h" |
18 #include "chrome/common/extensions/api/file_system_provider.h" | 18 #include "chrome/common/extensions/api/file_system_provider.h" |
19 #include "chrome/common/extensions/api/file_system_provider_capabilities/file_sy
stem_provider_capabilities_handler.h" | 19 #include "chrome/common/extensions/api/file_system_provider_capabilities/file_sy
stem_provider_capabilities_handler.h" |
20 #include "chrome/common/extensions/api/file_system_provider_internal.h" | 20 #include "chrome/common/extensions/api/file_system_provider_internal.h" |
21 #include "extensions/browser/event_router.h" | 21 #include "extensions/browser/event_router.h" |
22 #include "net/base/io_buffer.h" | 22 #include "net/base/io_buffer.h" |
23 #include "storage/browser/fileapi/async_file_util.h" | 23 #include "storage/browser/fileapi/async_file_util.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 const int execution_time = 0; | 175 const int execution_time = 0; |
176 | 176 |
177 base::ListValue value_as_list; | 177 base::ListValue value_as_list; |
178 value_as_list.Set(0, new base::StringValue(kFileSystemId)); | 178 value_as_list.Set(0, new base::StringValue(kFileSystemId)); |
179 value_as_list.Set(1, new base::FundamentalValue(kRequestId)); | 179 value_as_list.Set(1, new base::FundamentalValue(kRequestId)); |
180 value_as_list.Set( | 180 value_as_list.Set( |
181 2, base::BinaryValue::CreateWithCopiedBuffer(data.c_str(), data.size())); | 181 2, base::BinaryValue::CreateWithCopiedBuffer(data.c_str(), data.size())); |
182 value_as_list.Set(3, new base::FundamentalValue(has_more)); | 182 value_as_list.Set(3, new base::FundamentalValue(has_more)); |
183 value_as_list.Set(4, new base::FundamentalValue(execution_time)); | 183 value_as_list.Set(4, new base::FundamentalValue(execution_time)); |
184 | 184 |
185 scoped_ptr<Params> params(Params::Create(value_as_list)); | 185 std::unique_ptr<Params> params(Params::Create(value_as_list)); |
186 ASSERT_TRUE(params.get()); | 186 ASSERT_TRUE(params.get()); |
187 scoped_ptr<RequestValue> request_value( | 187 std::unique_ptr<RequestValue> request_value( |
188 RequestValue::CreateForReadFileSuccess(std::move(params))); | 188 RequestValue::CreateForReadFileSuccess(std::move(params))); |
189 ASSERT_TRUE(request_value.get()); | 189 ASSERT_TRUE(request_value.get()); |
190 | 190 |
191 read_file.OnSuccess(kRequestId, std::move(request_value), has_more); | 191 read_file.OnSuccess(kRequestId, std::move(request_value), has_more); |
192 | 192 |
193 ASSERT_EQ(1u, callback_logger.events().size()); | 193 ASSERT_EQ(1u, callback_logger.events().size()); |
194 CallbackLogger::Event* event = callback_logger.events()[0]; | 194 CallbackLogger::Event* event = callback_logger.events()[0]; |
195 EXPECT_EQ(kLength, event->chunk_length()); | 195 EXPECT_EQ(kLength, event->chunk_length()); |
196 EXPECT_FALSE(event->has_more()); | 196 EXPECT_FALSE(event->has_more()); |
197 EXPECT_EQ(data, std::string(io_buffer_->data(), kLength)); | 197 EXPECT_EQ(data, std::string(io_buffer_->data(), kLength)); |
(...skipping 12 matching lines...) Expand all Loading... |
210 kLength, | 210 kLength, |
211 base::Bind(&CallbackLogger::OnReadFile, | 211 base::Bind(&CallbackLogger::OnReadFile, |
212 base::Unretained(&callback_logger))); | 212 base::Unretained(&callback_logger))); |
213 read_file.SetDispatchEventImplForTesting( | 213 read_file.SetDispatchEventImplForTesting( |
214 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, | 214 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
215 base::Unretained(&dispatcher))); | 215 base::Unretained(&dispatcher))); |
216 | 216 |
217 EXPECT_TRUE(read_file.Execute(kRequestId)); | 217 EXPECT_TRUE(read_file.Execute(kRequestId)); |
218 | 218 |
219 read_file.OnError(kRequestId, | 219 read_file.OnError(kRequestId, |
220 scoped_ptr<RequestValue>(new RequestValue()), | 220 std::unique_ptr<RequestValue>(new RequestValue()), |
221 base::File::FILE_ERROR_TOO_MANY_OPENED); | 221 base::File::FILE_ERROR_TOO_MANY_OPENED); |
222 | 222 |
223 ASSERT_EQ(1u, callback_logger.events().size()); | 223 ASSERT_EQ(1u, callback_logger.events().size()); |
224 CallbackLogger::Event* event = callback_logger.events()[0]; | 224 CallbackLogger::Event* event = callback_logger.events()[0]; |
225 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, event->result()); | 225 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, event->result()); |
226 } | 226 } |
227 | 227 |
228 } // namespace operations | 228 } // namespace operations |
229 } // namespace file_system_provider | 229 } // namespace file_system_provider |
230 } // namespace chromeos | 230 } // namespace chromeos |
OLD | NEW |