| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "base/platform_file.h" | 7 #include "base/platform_file.h" |
| 8 #include "base/time.h" | 8 #include "base/time.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "webkit/chromeos/fileapi/memory_file_util.h" | 10 #include "webkit/chromeos/fileapi/memory_file_util.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 status.entries.insert(status.entries.begin(), entries.begin(), | 209 status.entries.insert(status.entries.begin(), entries.begin(), |
| 210 entries.end()); | 210 entries.end()); |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 | 213 |
| 214 void WriteToOpenedFile(int request_id, | 214 void WriteToOpenedFile(int request_id, |
| 215 const char* data, | 215 const char* data, |
| 216 int length, | 216 int length, |
| 217 PlatformFileError result, | 217 PlatformFileError result, |
| 218 AsyncFileStream* stream) { | 218 AsyncFileStream* stream) { |
| 219 DCHECK(status_map_.find(request_id) == status_map_.end()); |
| 219 CallbackStatus status; | 220 CallbackStatus status; |
| 220 status.type = CALLBACK_TYPE_OPEN; | 221 status.type = CALLBACK_TYPE_OPEN; |
| 221 status.result = result; | 222 status.result = result; |
| 223 status.file_stream = stream; |
| 222 status_map_[request_id] = status; | 224 status_map_[request_id] = status; |
| 223 stream->Write(data, length, GetReadWriteCallback(GetNextRequestId())); | 225 stream->Write(data, length, GetReadWriteCallback(GetNextRequestId())); |
| 224 delete stream; | |
| 225 } | 226 } |
| 226 | 227 |
| 227 scoped_ptr<MemoryFileUtil> file_util_; | 228 scoped_ptr<MemoryFileUtil> file_util_; |
| 228 std::map<int, CallbackStatus> status_map_; | 229 std::map<int, CallbackStatus> status_map_; |
| 229 int max_request_id_; | 230 int max_request_id_; |
| 230 | 231 |
| 231 DISALLOW_COPY_AND_ASSIGN(MemoryFileUtilTest); | 232 DISALLOW_COPY_AND_ASSIGN(MemoryFileUtilTest); |
| 232 }; | 233 }; |
| 233 | 234 |
| 234 TEST_F(MemoryFileUtilTest, TestCreateGetFileInfo) { | 235 TEST_F(MemoryFileUtilTest, TestCreateGetFileInfo) { |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 ASSERT_FALSE(it->is_directory); | 830 ASSERT_FALSE(it->is_directory); |
| 830 ASSERT_EQ(static_cast<int64>(kTestStringLength), it->size); | 831 ASSERT_EQ(static_cast<int64>(kTestStringLength), it->size); |
| 831 } else { | 832 } else { |
| 832 LOG(ERROR) << "Unexpected file: " << it->name; | 833 LOG(ERROR) << "Unexpected file: " << it->name; |
| 833 ASSERT_TRUE(false); | 834 ASSERT_TRUE(false); |
| 834 } | 835 } |
| 835 } | 836 } |
| 836 } | 837 } |
| 837 | 838 |
| 838 } // namespace fileapi | 839 } // namespace fileapi |
| OLD | NEW |