Home | History | Annotate | Download | only in storage
      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
      3 // found in the LICENSE file.
      4 
      5 #include "chrome/browser/local_discovery/storage/privet_filesystem_async_util.h"
      6 
      7 #include "chrome/browser/local_discovery/storage/path_util.h"
      8 #include "webkit/browser/fileapi/file_system_url.h"
      9 #include "webkit/common/blob/shareable_file_reference.h"
     10 
     11 namespace local_discovery {
     12 
     13 PrivetFileSystemAsyncUtil::PrivetFileSystemAsyncUtil(
     14     content::BrowserContext* browser_context) {
     15   DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
     16   operation_factory_ = new PrivetFileSystemOperationFactory(browser_context);
     17 }
     18 
     19 PrivetFileSystemAsyncUtil::~PrivetFileSystemAsyncUtil() {
     20   DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
     21   content::BrowserThread::DeleteSoon(
     22       content::BrowserThread::UI, FROM_HERE, operation_factory_);
     23 }
     24 
     25 void PrivetFileSystemAsyncUtil::CreateOrOpen(
     26     scoped_ptr<fileapi::FileSystemOperationContext> context,
     27     const fileapi::FileSystemURL& url,
     28     int file_flags,
     29     const CreateOrOpenCallback& callback) {
     30   NOTIMPLEMENTED();
     31   callback.Run(base::File(base::File::FILE_ERROR_INVALID_OPERATION),
     32                base::Closure());
     33 }
     34 
     35 void PrivetFileSystemAsyncUtil::EnsureFileExists(
     36     scoped_ptr<fileapi::FileSystemOperationContext> context,
     37     const fileapi::FileSystemURL& url,
     38     const EnsureFileExistsCallback& callback) {
     39     NOTIMPLEMENTED();
     40     callback.Run(base::File::FILE_ERROR_INVALID_OPERATION, false);
     41 }
     42 
     43 void PrivetFileSystemAsyncUtil::CreateDirectory(
     44     scoped_ptr<fileapi::FileSystemOperationContext> context,
     45     const fileapi::FileSystemURL& url,
     46     bool exclusive,
     47     bool recursive,
     48     const StatusCallback& callback) {
     49     NOTIMPLEMENTED();
     50     callback.Run(base::File::FILE_ERROR_INVALID_OPERATION);
     51 }
     52 
     53 void PrivetFileSystemAsyncUtil::GetFileInfo(
     54     scoped_ptr<fileapi::FileSystemOperationContext> context,
     55     const fileapi::FileSystemURL& url,
     56     const GetFileInfoCallback& callback) {
     57   ParsedPrivetPath parsed_path(url.path());
     58 
     59   if (parsed_path.path == "/") {
     60     base::File::Info file_info;
     61     file_info.is_directory = true;
     62     file_info.is_symbolic_link = false;
     63     callback.Run(base::File::FILE_OK, file_info);
     64     return;
     65   }
     66 
     67   content::BrowserThread::PostTask(
     68       content::BrowserThread::UI,
     69       FROM_HERE,
     70       base::Bind(&PrivetFileSystemOperationFactory::GetFileInfo,
     71                  operation_factory_->GetWeakPtr(),
     72                  url,
     73                  callback));
     74 }
     75 
     76 void PrivetFileSystemAsyncUtil::ReadDirectory(
     77     scoped_ptr<fileapi::FileSystemOperationContext> context,
     78     const fileapi::FileSystemURL& url,
     79     const ReadDirectoryCallback& callback) {
     80   content::BrowserThread::PostTask(
     81       content::BrowserThread::UI,
     82       FROM_HERE,
     83       base::Bind(&PrivetFileSystemOperationFactory::ReadDirectory,
     84                  operation_factory_->GetWeakPtr(),
     85                  url,
     86                  callback));
     87 }
     88 
     89 
     90 void PrivetFileSystemAsyncUtil::Touch(
     91     scoped_ptr<fileapi::FileSystemOperationContext> context,
     92     const fileapi::FileSystemURL& url,
     93     const base::Time& last_access_time,
     94     const base::Time& last_modified_time,
     95     const StatusCallback& callback) {
     96   NOTIMPLEMENTED();
     97   callback.Run(base::File::FILE_ERROR_INVALID_OPERATION);
     98 }
     99 
    100 void PrivetFileSystemAsyncUtil::Truncate(
    101     scoped_ptr<fileapi::FileSystemOperationContext> context,
    102     const fileapi::FileSystemURL& url,
    103     int64 length,
    104     const StatusCallback& callback) {
    105   NOTIMPLEMENTED();
    106   callback.Run(base::File::FILE_ERROR_INVALID_OPERATION);
    107 }
    108 
    109 void PrivetFileSystemAsyncUtil::CopyFileLocal(
    110     scoped_ptr<fileapi::FileSystemOperationContext> context,
    111     const fileapi::FileSystemURL& src_url,
    112     const fileapi::FileSystemURL& dest_url,
    113     CopyOrMoveOption option,
    114     const CopyFileProgressCallback& progress_callback,
    115     const StatusCallback& callback) {
    116   NOTIMPLEMENTED();
    117   callback.Run(base::File::FILE_ERROR_INVALID_OPERATION);
    118 }
    119 
    120 void PrivetFileSystemAsyncUtil::MoveFileLocal(
    121     scoped_ptr<fileapi::FileSystemOperationContext> context,
    122     const fileapi::FileSystemURL& src_url,
    123     const fileapi::FileSystemURL& dest_url,
    124     CopyOrMoveOption option,
    125     const StatusCallback& callback) {
    126   NOTIMPLEMENTED();
    127   callback.Run(base::File::FILE_ERROR_INVALID_OPERATION);
    128 }
    129 
    130 void PrivetFileSystemAsyncUtil::CopyInForeignFile(
    131     scoped_ptr<fileapi::FileSystemOperationContext> context,
    132     const base::FilePath& src_file_path,
    133     const fileapi::FileSystemURL& dest_url,
    134     const StatusCallback& callback) {
    135   NOTIMPLEMENTED();
    136   callback.Run(base::File::FILE_ERROR_INVALID_OPERATION);
    137 }
    138 
    139 void PrivetFileSystemAsyncUtil::DeleteFile(
    140     scoped_ptr<fileapi::FileSystemOperationContext> context,
    141     const fileapi::FileSystemURL& url,
    142     const StatusCallback& callback) {
    143   NOTIMPLEMENTED();
    144   callback.Run(base::File::FILE_ERROR_INVALID_OPERATION);
    145 }
    146 
    147 void PrivetFileSystemAsyncUtil::DeleteDirectory(
    148     scoped_ptr<fileapi::FileSystemOperationContext> context,
    149     const fileapi::FileSystemURL& url,
    150     const StatusCallback& callback) {
    151   NOTIMPLEMENTED();
    152   callback.Run(base::File::FILE_ERROR_INVALID_OPERATION);
    153 }
    154 
    155 void PrivetFileSystemAsyncUtil::DeleteRecursively(
    156     scoped_ptr<fileapi::FileSystemOperationContext> context,
    157     const fileapi::FileSystemURL& url,
    158     const StatusCallback& callback) {
    159   NOTIMPLEMENTED();
    160   callback.Run(base::File::FILE_ERROR_INVALID_OPERATION);
    161 }
    162 
    163 void PrivetFileSystemAsyncUtil::CreateSnapshotFile(
    164     scoped_ptr<fileapi::FileSystemOperationContext> context,
    165     const fileapi::FileSystemURL& url,
    166     const CreateSnapshotFileCallback& callback) {
    167   NOTIMPLEMENTED();
    168   callback.Run(base::File::FILE_ERROR_INVALID_OPERATION,
    169                base::File::Info(),
    170                base::FilePath(),
    171                scoped_refptr<webkit_blob::ShareableFileReference>());
    172 }
    173 
    174 }  // namespace local_discovery
    175