OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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 "content/common_child/fileapi/webfilewriter_impl.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "content/common/child_thread.h" | |
9 #include "content/common/fileapi/file_system_dispatcher.h" | |
10 | |
11 namespace content { | |
12 | |
13 namespace { | |
14 | |
15 inline FileSystemDispatcher* GetFileSystemDispatcher() { | |
16 return ChildThread::current()->file_system_dispatcher(); | |
17 } | |
18 | |
19 } // namespace | |
20 | |
21 WebFileWriterImpl::WebFileWriterImpl( | |
22 const GURL& path, WebKit::WebFileWriterClient* client) | |
23 : WebFileWriterBase(path, client), | |
24 request_id_(0) { | |
25 } | |
26 | |
27 WebFileWriterImpl::~WebFileWriterImpl() { | |
28 } | |
29 | |
30 void WebFileWriterImpl::DoTruncate(const GURL& path, int64 offset) { | |
31 // The FileSystemDispatcher takes ownership of the CallbackDispatcher. | |
32 GetFileSystemDispatcher()->Truncate( | |
33 path, offset, &request_id_, | |
34 base::Bind(&WebFileWriterImpl::DidFinish, AsWeakPtr())); | |
35 } | |
36 | |
37 void WebFileWriterImpl::DoWrite( | |
38 const GURL& path, const GURL& blob_url, int64 offset) { | |
39 GetFileSystemDispatcher()->Write( | |
40 path, blob_url, offset, &request_id_, | |
41 base::Bind(&WebFileWriterImpl::DidWrite, AsWeakPtr()), | |
42 base::Bind(&WebFileWriterImpl::DidFinish, AsWeakPtr())); | |
43 } | |
44 | |
45 void WebFileWriterImpl::DoCancel() { | |
46 GetFileSystemDispatcher()->Cancel( | |
47 request_id_, | |
48 base::Bind(&WebFileWriterImpl::DidFinish, AsWeakPtr())); | |
49 } | |
50 | |
51 } // namespace content | |
OLD | NEW |