OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/renderer_host/pepper/pepper_file_system_browser_host.h
" | 5 #include "content/browser/renderer_host/pepper/pepper_file_system_browser_host.h
" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "content/public/browser/browser_ppapi_host.h" | 9 #include "content/public/browser/browser_ppapi_host.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 : ResourceHost(host->GetPpapiHost(), instance, resource), | 59 : ResourceHost(host->GetPpapiHost(), instance, resource), |
60 browser_ppapi_host_(host), | 60 browser_ppapi_host_(host), |
61 weak_factory_(this), | 61 weak_factory_(this), |
62 type_(type), | 62 type_(type), |
63 opened_(false), | 63 opened_(false), |
64 fs_context_(NULL), | 64 fs_context_(NULL), |
65 called_open_(false) { | 65 called_open_(false) { |
66 } | 66 } |
67 | 67 |
68 PepperFileSystemBrowserHost::~PepperFileSystemBrowserHost() { | 68 PepperFileSystemBrowserHost::~PepperFileSystemBrowserHost() { |
69 if (fs_context_) | 69 if (fs_context_.get()) |
70 fs_context_->operation_runner()->Shutdown(); | 70 fs_context_->operation_runner()->Shutdown(); |
71 } | 71 } |
72 | 72 |
73 int32_t PepperFileSystemBrowserHost::OnResourceMessageReceived( | 73 int32_t PepperFileSystemBrowserHost::OnResourceMessageReceived( |
74 const IPC::Message& msg, | 74 const IPC::Message& msg, |
75 ppapi::host::HostMessageContext* context) { | 75 ppapi::host::HostMessageContext* context) { |
76 IPC_BEGIN_MESSAGE_MAP(PepperFileSystemBrowserHost, msg) | 76 IPC_BEGIN_MESSAGE_MAP(PepperFileSystemBrowserHost, msg) |
77 PPAPI_DISPATCH_HOST_RESOURCE_CALL( | 77 PPAPI_DISPATCH_HOST_RESOURCE_CALL( |
78 PpapiHostMsg_FileSystem_Open, | 78 PpapiHostMsg_FileSystem_Open, |
79 OnHostMsgOpen) | 79 OnHostMsgOpen) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 weak_factory_.GetWeakPtr(), | 130 weak_factory_.GetWeakPtr(), |
131 context->MakeReplyMessageContext(), | 131 context->MakeReplyMessageContext(), |
132 file_system_type)); | 132 file_system_type)); |
133 return PP_OK_COMPLETIONPENDING; | 133 return PP_OK_COMPLETIONPENDING; |
134 } | 134 } |
135 | 135 |
136 void PepperFileSystemBrowserHost::GotFileSystemContext( | 136 void PepperFileSystemBrowserHost::GotFileSystemContext( |
137 ppapi::host::ReplyMessageContext reply_context, | 137 ppapi::host::ReplyMessageContext reply_context, |
138 fileapi::FileSystemType file_system_type, | 138 fileapi::FileSystemType file_system_type, |
139 scoped_refptr<fileapi::FileSystemContext> fs_context) { | 139 scoped_refptr<fileapi::FileSystemContext> fs_context) { |
140 if (!fs_context) { | 140 if (!fs_context.get()) { |
141 OpenFileSystemComplete(reply_context, base::PLATFORM_FILE_ERROR_FAILED, | 141 OpenFileSystemComplete( |
142 std::string(), GURL()); | 142 reply_context, base::PLATFORM_FILE_ERROR_FAILED, std::string(), GURL()); |
143 return; | 143 return; |
144 } | 144 } |
145 GURL origin = browser_ppapi_host_->GetDocumentURLForInstance( | 145 GURL origin = browser_ppapi_host_->GetDocumentURLForInstance( |
146 pp_instance()).GetOrigin(); | 146 pp_instance()).GetOrigin(); |
147 fs_context->OpenFileSystem(origin, file_system_type, | 147 fs_context->OpenFileSystem(origin, file_system_type, |
148 fileapi::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, | 148 fileapi::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, |
149 base::Bind(&PepperFileSystemBrowserHost::OpenFileSystemComplete, | 149 base::Bind(&PepperFileSystemBrowserHost::OpenFileSystemComplete, |
150 weak_factory_.GetWeakPtr(), | 150 weak_factory_.GetWeakPtr(), |
151 reply_context)); | 151 reply_context)); |
152 fs_context_ = fs_context; | 152 fs_context_ = fs_context; |
(...skipping 22 matching lines...) Expand all Loading... |
175 return PP_ERROR_BADARGUMENT; | 175 return PP_ERROR_BADARGUMENT; |
176 const GURL& url = | 176 const GURL& url = |
177 browser_ppapi_host_->GetDocumentURLForInstance(pp_instance()); | 177 browser_ppapi_host_->GetDocumentURLForInstance(pp_instance()); |
178 root_url_ = GURL(fileapi::GetIsolatedFileSystemRootURIString( | 178 root_url_ = GURL(fileapi::GetIsolatedFileSystemRootURIString( |
179 url.GetOrigin(), fsid, "crxfs")); | 179 url.GetOrigin(), fsid, "crxfs")); |
180 opened_ = true; | 180 opened_ = true; |
181 return PP_OK; | 181 return PP_OK; |
182 } | 182 } |
183 | 183 |
184 } // namespace content | 184 } // namespace content |
OLD | NEW |