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

Side by Side Diff: webkit/fileapi/file_system_url_request_job_base.cc

Issue 6864040: Fixed file/directory url resolution for external mount point provider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 #include "webkit/fileapi/file_system_url_request_job_base.h"
5
6 #include "base/message_loop.h"
7 #include "net/base/net_errors.h"
8 #include "net/url_request/url_request.h"
9
10 using net::URLRequest;
11 using net::URLRequestJob;
12 using net::URLRequestStatus;
13
14 namespace fileapi {
15
16 class LocalPathCallbackDispatcher : public FileSystemCallbackDispatcher {
17 public:
18 explicit LocalPathCallbackDispatcher(
19 FileSystemURLRequestJobBase* request)
20 : request_(request),
21 io_loop_(base::MessageLoopProxy::CreateForCurrentThread()) {
22 DCHECK(request_);
23 }
24
25 // fileapi::FileSystemCallbackDispatcher overrides.
26 virtual void DidSucceed() OVERRIDE {
27 NOTREACHED();
28 }
29
30 virtual void DidGetLocalPath(const FilePath& local_path) {
31 io_loop_->PostTask(FROM_HERE,
32 NewRunnableMethod(request_,
33 &FileSystemURLRequestJobBase::OnGetLocalPath,
34 local_path));
35 }
36
37 virtual void DidReadMetadata(const base::PlatformFileInfo& info,
38 const FilePath& unused) OVERRIDE {
39 NOTREACHED();
40 }
41
42 virtual void DidReadDirectory(
43 const std::vector<base::FileUtilProxy::Entry>& entries,
44 bool has_more) OVERRIDE {
45 NOTREACHED();
46 }
47
48 virtual void DidWrite(int64 bytes, bool complete) OVERRIDE {
49 NOTREACHED();
50 }
51
52 virtual void DidOpenFileSystem(const std::string& name,
53 const GURL& root_path) OVERRIDE {
54 NOTREACHED();
55 }
56
57 virtual void DidFail(base::PlatformFileError error_code) OVERRIDE {
58 io_loop_->PostTask(FROM_HERE,
59 NewRunnableMethod(request_,
60 &FileSystemURLRequestJobBase::RespondFailedOnIOThread,
61 error_code));
62 }
63
64 private:
65 FileSystemURLRequestJobBase* request_;
66 scoped_refptr<base::MessageLoopProxy> io_loop_;
67 DISALLOW_COPY_AND_ASSIGN(LocalPathCallbackDispatcher);
68 };
69
70 FileSystemURLRequestJobBase::FileSystemURLRequestJobBase(
71 URLRequest* request, FileSystemContext* file_system_context,
72 scoped_refptr<base::MessageLoopProxy> file_thread_proxy)
73 : URLRequestJob(request),
74 file_system_context_(file_system_context),
75 file_thread_proxy_(file_thread_proxy) {
76 }
77
78 FileSystemOperation* FileSystemURLRequestJobBase::GetNewOperation() {
79 LocalPathCallbackDispatcher* dispatcher =
80 new LocalPathCallbackDispatcher(this);
81 FileSystemOperation* operation = new FileSystemOperation(
82 dispatcher,
83 file_thread_proxy_,
84 file_system_context_,
85 NULL);
86 return operation;
87 }
88
89 void FileSystemURLRequestJobBase::StartAsync() {
90 GetNewOperation()->GetLocalPath(request_->url());
91 }
92
93 void FileSystemURLRequestJobBase::RespondFailedOnIOThread(int error_code) {
94 int rv = net::ERR_FILE_NOT_FOUND;
95 if (error_code == base::PLATFORM_FILE_ERROR_INVALID_URL)
96 rv = net::ERR_INVALID_URL;
97 NotifyFailed(rv);
98 }
99
100 void FileSystemURLRequestJobBase::NotifyFailed(int rv) {
101 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv));
102 }
103
104 void FileSystemURLRequestJobBase::OnGetLocalPath(
105 const FilePath& local_path) {
106 DidGetLocalPath(local_path);
107 }
108
109 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698