| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "storage/browser/fileapi/recursive_operation_delegate.h" | 5 #include "storage/browser/fileapi/recursive_operation_delegate.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 const StatusCallback& callback) | 43 const StatusCallback& callback) |
| 44 : storage::RecursiveOperationDelegate(file_system_context), | 44 : storage::RecursiveOperationDelegate(file_system_context), |
| 45 root_(root), | 45 root_(root), |
| 46 callback_(callback), | 46 callback_(callback), |
| 47 weak_factory_(this) {} | 47 weak_factory_(this) {} |
| 48 virtual ~LoggingRecursiveOperation() {} | 48 virtual ~LoggingRecursiveOperation() {} |
| 49 | 49 |
| 50 const std::vector<LogEntry>& log_entries() const { return log_entries_; } | 50 const std::vector<LogEntry>& log_entries() const { return log_entries_; } |
| 51 | 51 |
| 52 // RecursiveOperationDelegate overrides. | 52 // RecursiveOperationDelegate overrides. |
| 53 virtual void Run() OVERRIDE { | 53 virtual void Run() override { |
| 54 NOTREACHED(); | 54 NOTREACHED(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 virtual void RunRecursively() OVERRIDE { | 57 virtual void RunRecursively() override { |
| 58 StartRecursiveOperation(root_, callback_); | 58 StartRecursiveOperation(root_, callback_); |
| 59 } | 59 } |
| 60 | 60 |
| 61 virtual void ProcessFile(const FileSystemURL& url, | 61 virtual void ProcessFile(const FileSystemURL& url, |
| 62 const StatusCallback& callback) OVERRIDE { | 62 const StatusCallback& callback) override { |
| 63 RecordLogEntry(LogEntry::PROCESS_FILE, url); | 63 RecordLogEntry(LogEntry::PROCESS_FILE, url); |
| 64 operation_runner()->GetMetadata( | 64 operation_runner()->GetMetadata( |
| 65 url, | 65 url, |
| 66 base::Bind(&LoggingRecursiveOperation::DidGetMetadata, | 66 base::Bind(&LoggingRecursiveOperation::DidGetMetadata, |
| 67 weak_factory_.GetWeakPtr(), callback)); | 67 weak_factory_.GetWeakPtr(), callback)); |
| 68 } | 68 } |
| 69 | 69 |
| 70 virtual void ProcessDirectory(const FileSystemURL& url, | 70 virtual void ProcessDirectory(const FileSystemURL& url, |
| 71 const StatusCallback& callback) OVERRIDE { | 71 const StatusCallback& callback) override { |
| 72 RecordLogEntry(LogEntry::PROCESS_DIRECTORY, url); | 72 RecordLogEntry(LogEntry::PROCESS_DIRECTORY, url); |
| 73 callback.Run(base::File::FILE_OK); | 73 callback.Run(base::File::FILE_OK); |
| 74 } | 74 } |
| 75 | 75 |
| 76 virtual void PostProcessDirectory(const FileSystemURL& url, | 76 virtual void PostProcessDirectory(const FileSystemURL& url, |
| 77 const StatusCallback& callback) OVERRIDE { | 77 const StatusCallback& callback) override { |
| 78 RecordLogEntry(LogEntry::POST_PROCESS_DIRECTORY, url); | 78 RecordLogEntry(LogEntry::POST_PROCESS_DIRECTORY, url); |
| 79 callback.Run(base::File::FILE_OK); | 79 callback.Run(base::File::FILE_OK); |
| 80 } | 80 } |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 void RecordLogEntry(LogEntry::Type type, const FileSystemURL& url) { | 83 void RecordLogEntry(LogEntry::Type type, const FileSystemURL& url) { |
| 84 LogEntry entry; | 84 LogEntry entry; |
| 85 entry.type = type; | 85 entry.type = type; |
| 86 entry.url = url; | 86 entry.url = url; |
| 87 log_entries_.push_back(entry); | 87 log_entries_.push_back(entry); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 return; | 125 return; |
| 126 } | 126 } |
| 127 | 127 |
| 128 operation->Cancel(); | 128 operation->Cancel(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 } // namespace | 131 } // namespace |
| 132 | 132 |
| 133 class RecursiveOperationDelegateTest : public testing::Test { | 133 class RecursiveOperationDelegateTest : public testing::Test { |
| 134 protected: | 134 protected: |
| 135 virtual void SetUp() OVERRIDE { | 135 virtual void SetUp() override { |
| 136 EXPECT_TRUE(base_.CreateUniqueTempDir()); | 136 EXPECT_TRUE(base_.CreateUniqueTempDir()); |
| 137 sandbox_file_system_.SetUp(base_.path().AppendASCII("filesystem")); | 137 sandbox_file_system_.SetUp(base_.path().AppendASCII("filesystem")); |
| 138 } | 138 } |
| 139 | 139 |
| 140 virtual void TearDown() OVERRIDE { | 140 virtual void TearDown() override { |
| 141 sandbox_file_system_.TearDown(); | 141 sandbox_file_system_.TearDown(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 scoped_ptr<FileSystemOperationContext> NewContext() { | 144 scoped_ptr<FileSystemOperationContext> NewContext() { |
| 145 FileSystemOperationContext* context = | 145 FileSystemOperationContext* context = |
| 146 sandbox_file_system_.NewOperationContext(); | 146 sandbox_file_system_.NewOperationContext(); |
| 147 // Grant enough quota for all test cases. | 147 // Grant enough quota for all test cases. |
| 148 context->set_allowed_bytes_growth(1000000); | 148 context->set_allowed_bytes_growth(1000000); |
| 149 return make_scoped_ptr(context); | 149 return make_scoped_ptr(context); |
| 150 } | 150 } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 base::Bind(&ReportStatus, &error))); | 275 base::Bind(&ReportStatus, &error))); |
| 276 operation->RunRecursively(); | 276 operation->RunRecursively(); |
| 277 | 277 |
| 278 // Invoke Cancel(), after 5 times message posting. | 278 // Invoke Cancel(), after 5 times message posting. |
| 279 CallCancelLater(operation.get(), 5); | 279 CallCancelLater(operation.get(), 5); |
| 280 base::RunLoop().RunUntilIdle(); | 280 base::RunLoop().RunUntilIdle(); |
| 281 ASSERT_EQ(base::File::FILE_ERROR_ABORT, error); | 281 ASSERT_EQ(base::File::FILE_ERROR_ABORT, error); |
| 282 } | 282 } |
| 283 | 283 |
| 284 } // namespace content | 284 } // namespace content |
| OLD | NEW |