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 27 matching lines...) Expand all Loading... |
38 FileSystemURL url; | 38 FileSystemURL url; |
39 }; | 39 }; |
40 | 40 |
41 LoggingRecursiveOperation(FileSystemContext* file_system_context, | 41 LoggingRecursiveOperation(FileSystemContext* file_system_context, |
42 const FileSystemURL& root, | 42 const FileSystemURL& root, |
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 ~LoggingRecursiveOperation() override {} |
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 void Run() override { NOTREACHED(); } |
54 NOTREACHED(); | |
55 } | |
56 | 54 |
57 virtual void RunRecursively() override { | 55 void RunRecursively() override { StartRecursiveOperation(root_, callback_); } |
58 StartRecursiveOperation(root_, callback_); | |
59 } | |
60 | 56 |
61 virtual void ProcessFile(const FileSystemURL& url, | 57 void ProcessFile(const FileSystemURL& url, |
62 const StatusCallback& callback) override { | 58 const StatusCallback& callback) override { |
63 RecordLogEntry(LogEntry::PROCESS_FILE, url); | 59 RecordLogEntry(LogEntry::PROCESS_FILE, url); |
64 operation_runner()->GetMetadata( | 60 operation_runner()->GetMetadata( |
65 url, | 61 url, |
66 base::Bind(&LoggingRecursiveOperation::DidGetMetadata, | 62 base::Bind(&LoggingRecursiveOperation::DidGetMetadata, |
67 weak_factory_.GetWeakPtr(), callback)); | 63 weak_factory_.GetWeakPtr(), callback)); |
68 } | 64 } |
69 | 65 |
70 virtual void ProcessDirectory(const FileSystemURL& url, | 66 void ProcessDirectory(const FileSystemURL& url, |
71 const StatusCallback& callback) override { | 67 const StatusCallback& callback) override { |
72 RecordLogEntry(LogEntry::PROCESS_DIRECTORY, url); | 68 RecordLogEntry(LogEntry::PROCESS_DIRECTORY, url); |
73 callback.Run(base::File::FILE_OK); | 69 callback.Run(base::File::FILE_OK); |
74 } | 70 } |
75 | 71 |
76 virtual void PostProcessDirectory(const FileSystemURL& url, | 72 void PostProcessDirectory(const FileSystemURL& url, |
77 const StatusCallback& callback) override { | 73 const StatusCallback& callback) override { |
78 RecordLogEntry(LogEntry::POST_PROCESS_DIRECTORY, url); | 74 RecordLogEntry(LogEntry::POST_PROCESS_DIRECTORY, url); |
79 callback.Run(base::File::FILE_OK); | 75 callback.Run(base::File::FILE_OK); |
80 } | 76 } |
81 | 77 |
82 private: | 78 private: |
83 void RecordLogEntry(LogEntry::Type type, const FileSystemURL& url) { | 79 void RecordLogEntry(LogEntry::Type type, const FileSystemURL& url) { |
84 LogEntry entry; | 80 LogEntry entry; |
85 entry.type = type; | 81 entry.type = type; |
86 entry.url = url; | 82 entry.url = url; |
87 log_entries_.push_back(entry); | 83 log_entries_.push_back(entry); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 base::Bind(&ReportStatus, &error))); | 271 base::Bind(&ReportStatus, &error))); |
276 operation->RunRecursively(); | 272 operation->RunRecursively(); |
277 | 273 |
278 // Invoke Cancel(), after 5 times message posting. | 274 // Invoke Cancel(), after 5 times message posting. |
279 CallCancelLater(operation.get(), 5); | 275 CallCancelLater(operation.get(), 5); |
280 base::RunLoop().RunUntilIdle(); | 276 base::RunLoop().RunUntilIdle(); |
281 ASSERT_EQ(base::File::FILE_ERROR_ABORT, error); | 277 ASSERT_EQ(base::File::FILE_ERROR_ABORT, error); |
282 } | 278 } |
283 | 279 |
284 } // namespace content | 280 } // namespace content |
OLD | NEW |