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

Side by Side Diff: chrome/browser/chromeos/drive/file_system_backend_delegate.cc

Issue 148913005: Create fileapi/ subdirectory under c/b/cros/drive. (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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/drive/file_system_backend_delegate.h"
6
7 #include "base/bind.h"
8 #include "base/files/file_path.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/chromeos/drive/async_file_util.h"
11 #include "chrome/browser/chromeos/drive/file_system_util.h"
12 #include "chrome/browser/chromeos/drive/webkit_file_stream_reader_impl.h"
13 #include "chrome/browser/chromeos/drive/webkit_file_stream_writer_impl.h"
14 #include "chrome/browser/profiles/profile.h"
15 #include "content/public/browser/browser_context.h"
16 #include "content/public/browser/browser_thread.h"
17 #include "webkit/browser/blob/file_stream_reader.h"
18 #include "webkit/browser/fileapi/async_file_util.h"
19 #include "webkit/browser/fileapi/file_system_context.h"
20 #include "webkit/browser/fileapi/file_system_url.h"
21
22 using content::BrowserThread;
23
24 namespace drive {
25
26 FileSystemBackendDelegate::FileSystemBackendDelegate(
27 content::BrowserContext* browser_context)
28 : profile_id_(Profile::FromBrowserContext(browser_context)),
29 async_file_util_(new internal::AsyncFileUtil(
30 base::Bind(&util::GetFileSystemByProfileId, profile_id_))) {
31 DCHECK(profile_id_);
32 }
33
34 FileSystemBackendDelegate::~FileSystemBackendDelegate() {
35 }
36
37 fileapi::AsyncFileUtil* FileSystemBackendDelegate::GetAsyncFileUtil(
38 fileapi::FileSystemType type) {
39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
40 DCHECK_EQ(fileapi::kFileSystemTypeDrive, type);
41 return async_file_util_.get();
42 }
43
44 scoped_ptr<webkit_blob::FileStreamReader>
45 FileSystemBackendDelegate::CreateFileStreamReader(
46 const fileapi::FileSystemURL& url,
47 int64 offset,
48 const base::Time& expected_modification_time,
49 fileapi::FileSystemContext* context) {
50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
51 DCHECK_EQ(fileapi::kFileSystemTypeDrive, url.type());
52
53 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
54 if (file_path.empty())
55 return scoped_ptr<webkit_blob::FileStreamReader>();
56
57 return scoped_ptr<webkit_blob::FileStreamReader>(
58 new internal::WebkitFileStreamReaderImpl(
59 base::Bind(&util::GetFileSystemByProfileId, profile_id_),
60 context->default_file_task_runner(),
61 file_path, offset, expected_modification_time));
62 }
63
64 scoped_ptr<fileapi::FileStreamWriter>
65 FileSystemBackendDelegate::CreateFileStreamWriter(
66 const fileapi::FileSystemURL& url,
67 int64 offset,
68 fileapi::FileSystemContext* context) {
69 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
70 DCHECK_EQ(fileapi::kFileSystemTypeDrive, url.type());
71
72 base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
73 // Hosted documents don't support stream writer.
74 if (file_path.empty() || util::HasGDocFileExtension(file_path))
75 return scoped_ptr<fileapi::FileStreamWriter>();
76
77 return scoped_ptr<fileapi::FileStreamWriter>(
78 new internal::WebkitFileStreamWriterImpl(
79 base::Bind(&util::GetFileSystemByProfileId, profile_id_),
80 context->default_file_task_runner(),file_path, offset));
81 }
82
83 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/file_system_backend_delegate.h ('k') | chrome/browser/chromeos/drive/fileapi/async_file_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698