Upstream version 10.38.222.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / local_discovery / storage / privet_filesystem_backend.cc
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_backend.h"
6
7 #include <string>
8
9 #include "chrome/browser/local_discovery/storage/privet_filesystem_async_util.h"
10 #include "chrome/browser/local_discovery/storage/privet_filesystem_constants.h"
11 #include "webkit/browser/fileapi/file_system_operation.h"
12 #include "webkit/browser/fileapi/file_system_url.h"
13
14 namespace local_discovery {
15
16 PrivetFileSystemBackend::PrivetFileSystemBackend(
17     fileapi::ExternalMountPoints* mount_points,
18     content::BrowserContext* browser_context)
19     : mount_points_(mount_points),
20       async_util_(new PrivetFileSystemAsyncUtil(browser_context)) {
21 }
22
23 PrivetFileSystemBackend::~PrivetFileSystemBackend() {
24 }
25
26 bool PrivetFileSystemBackend::CanHandleType(
27     fileapi::FileSystemType type) const {
28   return (type == fileapi::kFileSystemTypeCloudDevice);
29 }
30
31 void PrivetFileSystemBackend::Initialize(fileapi::FileSystemContext* context) {
32   mount_points_->RegisterFileSystem(
33       "privet",
34       fileapi::kFileSystemTypeCloudDevice,
35       fileapi::FileSystemMountOption(),
36       base::FilePath(kPrivetFilePath));
37 }
38
39 void PrivetFileSystemBackend::ResolveURL(
40     const fileapi::FileSystemURL& url,
41     fileapi::OpenFileSystemMode mode,
42     const OpenFileSystemCallback& callback) {
43   // TODO(noamsml): Provide a proper root url and a proper name.
44   GURL root_url = GURL(
45       fileapi::GetExternalFileSystemRootURIString(url.origin(), std::string()));
46   callback.Run(root_url, std::string(), base::File::FILE_OK);
47 }
48
49 fileapi::FileSystemQuotaUtil* PrivetFileSystemBackend::GetQuotaUtil() {
50   // No quota support.
51   return NULL;
52 }
53
54 fileapi::AsyncFileUtil* PrivetFileSystemBackend::GetAsyncFileUtil(
55     fileapi::FileSystemType type) {
56   return async_util_.get();
57 }
58
59 fileapi::CopyOrMoveFileValidatorFactory*
60 PrivetFileSystemBackend::GetCopyOrMoveFileValidatorFactory(
61     fileapi::FileSystemType type, base::File::Error* error_code) {
62   DCHECK(error_code);
63   *error_code = base::File::FILE_OK;
64   return NULL;
65 }
66
67 fileapi::FileSystemOperation*
68 PrivetFileSystemBackend::CreateFileSystemOperation(
69     const fileapi::FileSystemURL& url,
70     fileapi::FileSystemContext* context,
71     base::File::Error* error_code) const {
72   return fileapi::FileSystemOperation::Create(
73       url, context,
74       make_scoped_ptr(new fileapi::FileSystemOperationContext(context)));
75 }
76
77 bool PrivetFileSystemBackend::SupportsStreaming(
78     const fileapi::FileSystemURL& url) const {
79   return false;
80 }
81
82 scoped_ptr<webkit_blob::FileStreamReader>
83 PrivetFileSystemBackend::CreateFileStreamReader(
84     const fileapi::FileSystemURL& url,
85     int64 offset,
86     const base::Time& expected_modification_time,
87     fileapi::FileSystemContext* context) const {
88   return scoped_ptr<webkit_blob::FileStreamReader>();
89 }
90
91 scoped_ptr<fileapi::FileStreamWriter>
92 PrivetFileSystemBackend::CreateFileStreamWriter(
93     const fileapi::FileSystemURL& url,
94     int64 offset,
95     fileapi::FileSystemContext* context) const {
96   return scoped_ptr<fileapi::FileStreamWriter>();
97 }
98
99 }  // namespace local_discovery