Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: chrome/browser/local_discovery/storage/privet_filesystem_async_util.cc

Issue 141703022: Support for file listing in privet local filesystem (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/local_discovery/storage/privet_filesystem_async_util.h" 5 #include "chrome/browser/local_discovery/storage/privet_filesystem_async_util.h"
6 6
7 #include "base/platform_file.h" 7 #include "base/platform_file.h"
8 #include "base/stl_util.h"
8 #include "webkit/browser/fileapi/file_system_url.h" 9 #include "webkit/browser/fileapi/file_system_url.h"
9 #include "webkit/common/blob/shareable_file_reference.h" 10 #include "webkit/common/blob/shareable_file_reference.h"
10 11
11 namespace local_discovery { 12 namespace local_discovery {
12 13
14 PrivetFileSystemAsyncUtil::PrivetFileSystemAsyncUtil(
15 content::BrowserContext* browser_context)
16 : browser_context_(browser_context) {
17 }
18
19 PrivetFileSystemAsyncUtil::~PrivetFileSystemAsyncUtil() {
20 }
21
13 void PrivetFileSystemAsyncUtil::CreateOrOpen( 22 void PrivetFileSystemAsyncUtil::CreateOrOpen(
14 scoped_ptr<fileapi::FileSystemOperationContext> context, 23 scoped_ptr<fileapi::FileSystemOperationContext> context,
15 const fileapi::FileSystemURL& url, 24 const fileapi::FileSystemURL& url,
16 int file_flags, 25 int file_flags,
17 const CreateOrOpenCallback& callback) { 26 const CreateOrOpenCallback& callback) {
18 NOTIMPLEMENTED(); 27 NOTIMPLEMENTED();
19 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION, 28 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION,
20 base::PassPlatformFile(NULL), 29 base::PassPlatformFile(NULL),
21 base::Closure()); 30 base::Closure());
22 } 31 }
(...skipping 15 matching lines...) Expand all
38 NOTIMPLEMENTED(); 47 NOTIMPLEMENTED();
39 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); 48 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION);
40 } 49 }
41 50
42 void PrivetFileSystemAsyncUtil::GetFileInfo( 51 void PrivetFileSystemAsyncUtil::GetFileInfo(
43 scoped_ptr<fileapi::FileSystemOperationContext> context, 52 scoped_ptr<fileapi::FileSystemOperationContext> context,
44 const fileapi::FileSystemURL& url, 53 const fileapi::FileSystemURL& url,
45 const GetFileInfoCallback& callback) { 54 const GetFileInfoCallback& callback) {
46 base::File::Info file_info; 55 base::File::Info file_info;
47 56
48 if (url.path() == base::FilePath(FILE_PATH_LITERAL("/privet"))) { 57 file_info.size = 20;
49 file_info.size = 20; 58 file_info.is_directory = true;
50 file_info.is_directory = true; 59 file_info.is_symbolic_link = false;
51 file_info.is_symbolic_link = false; 60
52 } else {
53 file_info.size = 3000;
54 file_info.is_directory = false;
55 file_info.is_symbolic_link = false;
56 }
57 callback.Run(base::File::FILE_OK, file_info); 61 callback.Run(base::File::FILE_OK, file_info);
58 } 62 }
59 63
60 void PrivetFileSystemAsyncUtil::ReadDirectory( 64 void PrivetFileSystemAsyncUtil::ReadDirectory(
61 scoped_ptr<fileapi::FileSystemOperationContext> context, 65 scoped_ptr<fileapi::FileSystemOperationContext> context,
62 const fileapi::FileSystemURL& url, 66 const fileapi::FileSystemURL& url,
63 const ReadDirectoryCallback& callback) { 67 const ReadDirectoryCallback& callback) {
64 EntryList entry_list; 68 PrivetFileSystemAsyncOperation* operation = new PrivetFileSystemListOperation(
69 url.path(),
70 browser_context_,
71 this,
72 callback);
73 async_operations_.insert(operation);
74 operation->Start();
75 }
65 76
66 fileapi::DirectoryEntry entry("Random file",
67 fileapi::DirectoryEntry::FILE,
68 3000,
69 base::Time());
70 entry_list.push_back(entry);
71
72 callback.Run(base::File::FILE_OK, entry_list, false);
73 }
74 77
75 void PrivetFileSystemAsyncUtil::Touch( 78 void PrivetFileSystemAsyncUtil::Touch(
76 scoped_ptr<fileapi::FileSystemOperationContext> context, 79 scoped_ptr<fileapi::FileSystemOperationContext> context,
77 const fileapi::FileSystemURL& url, 80 const fileapi::FileSystemURL& url,
78 const base::Time& last_access_time, 81 const base::Time& last_access_time,
79 const base::Time& last_modified_time, 82 const base::Time& last_modified_time,
80 const StatusCallback& callback) { 83 const StatusCallback& callback) {
81 NOTIMPLEMENTED(); 84 NOTIMPLEMENTED();
82 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); 85 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION);
83 } 86 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 scoped_ptr<fileapi::FileSystemOperationContext> context, 152 scoped_ptr<fileapi::FileSystemOperationContext> context,
150 const fileapi::FileSystemURL& url, 153 const fileapi::FileSystemURL& url,
151 const CreateSnapshotFileCallback& callback) { 154 const CreateSnapshotFileCallback& callback) {
152 NOTIMPLEMENTED(); 155 NOTIMPLEMENTED();
153 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION, 156 callback.Run(base::File::FILE_ERROR_INVALID_OPERATION,
154 base::File::Info(), 157 base::File::Info(),
155 base::FilePath(), 158 base::FilePath(),
156 scoped_refptr<webkit_blob::ShareableFileReference>()); 159 scoped_refptr<webkit_blob::ShareableFileReference>());
157 } 160 }
158 161
162 void PrivetFileSystemAsyncUtil::RemoveOperation(
163 PrivetFileSystemAsyncOperation* operation) {
164 async_operations_.erase(operation);
165 delete operation;
166 }
167
168 void PrivetFileSystemAsyncUtil::RemoveAllOperations() {
169 STLDeleteElements(&async_operations_);
170 }
171
159 } // namespace local_discovery 172 } // namespace local_discovery
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698