OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/fileapi/fileapi_message_filter.h" | 5 #include "content/browser/fileapi/fileapi_message_filter.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 if (message.type() == FileSystemHostMsg_SyncGetPlatformPath::ID) | 138 if (message.type() == FileSystemHostMsg_SyncGetPlatformPath::ID) |
139 return context_->default_file_task_runner(); | 139 return context_->default_file_task_runner(); |
140 return NULL; | 140 return NULL; |
141 } | 141 } |
142 | 142 |
143 bool FileAPIMessageFilter::OnMessageReceived(const IPC::Message& message) { | 143 bool FileAPIMessageFilter::OnMessageReceived(const IPC::Message& message) { |
144 bool handled = true; | 144 bool handled = true; |
145 IPC_BEGIN_MESSAGE_MAP(FileAPIMessageFilter, message) | 145 IPC_BEGIN_MESSAGE_MAP(FileAPIMessageFilter, message) |
146 IPC_MESSAGE_HANDLER(FileSystemHostMsg_OpenFileSystem, OnOpenFileSystem) | 146 IPC_MESSAGE_HANDLER(FileSystemHostMsg_OpenFileSystem, OnOpenFileSystem) |
147 IPC_MESSAGE_HANDLER(FileSystemHostMsg_ResolveURL, OnResolveURL) | 147 IPC_MESSAGE_HANDLER(FileSystemHostMsg_ResolveURL, OnResolveURL) |
148 IPC_MESSAGE_HANDLER(FileSystemHostMsg_DeleteFileSystem, OnDeleteFileSystem) | |
149 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Move, OnMove) | 148 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Move, OnMove) |
150 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Copy, OnCopy) | 149 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Copy, OnCopy) |
151 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Remove, OnRemove) | 150 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Remove, OnRemove) |
152 IPC_MESSAGE_HANDLER(FileSystemHostMsg_ReadMetadata, OnReadMetadata) | 151 IPC_MESSAGE_HANDLER(FileSystemHostMsg_ReadMetadata, OnReadMetadata) |
153 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Create, OnCreate) | 152 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Create, OnCreate) |
154 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Exists, OnExists) | 153 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Exists, OnExists) |
155 IPC_MESSAGE_HANDLER(FileSystemHostMsg_ReadDirectory, OnReadDirectory) | 154 IPC_MESSAGE_HANDLER(FileSystemHostMsg_ReadDirectory, OnReadDirectory) |
156 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Write, OnWrite) | 155 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Write, OnWrite) |
157 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Truncate, OnTruncate) | 156 IPC_MESSAGE_HANDLER(FileSystemHostMsg_Truncate, OnTruncate) |
158 IPC_MESSAGE_HANDLER(FileSystemHostMsg_TouchFile, OnTouchFile) | 157 IPC_MESSAGE_HANDLER(FileSystemHostMsg_TouchFile, OnTouchFile) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 if (!security_policy_->CanReadFileSystemFile(process_id_, url)) { | 204 if (!security_policy_->CanReadFileSystemFile(process_id_, url)) { |
206 Send(new FileSystemMsg_DidFail(request_id, | 205 Send(new FileSystemMsg_DidFail(request_id, |
207 base::File::FILE_ERROR_SECURITY)); | 206 base::File::FILE_ERROR_SECURITY)); |
208 return; | 207 return; |
209 } | 208 } |
210 | 209 |
211 context_->ResolveURL(url, base::Bind( | 210 context_->ResolveURL(url, base::Bind( |
212 &FileAPIMessageFilter::DidResolveURL, this, request_id)); | 211 &FileAPIMessageFilter::DidResolveURL, this, request_id)); |
213 } | 212 } |
214 | 213 |
215 void FileAPIMessageFilter::OnDeleteFileSystem(int request_id, | |
216 const GURL& origin_url, | |
217 storage::FileSystemType type) { | |
218 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
219 context_->DeleteFileSystem(origin_url, type, base::Bind( | |
220 &FileAPIMessageFilter::DidDeleteFileSystem, this, request_id)); | |
221 } | |
222 | |
223 void FileAPIMessageFilter::OnMove( | 214 void FileAPIMessageFilter::OnMove( |
224 int request_id, const GURL& src_path, const GURL& dest_path) { | 215 int request_id, const GURL& src_path, const GURL& dest_path) { |
225 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 216 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
226 FileSystemURL src_url(context_->CrackURL(src_path)); | 217 FileSystemURL src_url(context_->CrackURL(src_path)); |
227 FileSystemURL dest_url(context_->CrackURL(dest_path)); | 218 FileSystemURL dest_url(context_->CrackURL(dest_path)); |
228 if (!ValidateFileSystemURL(request_id, src_url) || | 219 if (!ValidateFileSystemURL(request_id, src_url) || |
229 !ValidateFileSystemURL(request_id, dest_url)) { | 220 !ValidateFileSystemURL(request_id, dest_url)) { |
230 return; | 221 return; |
231 } | 222 } |
232 if (!security_policy_->CanReadFileSystemFile(process_id_, src_url) || | 223 if (!security_policy_->CanReadFileSystemFile(process_id_, src_url) || |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 request_id, | 685 request_id, |
695 info, | 686 info, |
696 file_path, | 687 file_path, |
697 type == storage::FileSystemContext::RESOLVED_ENTRY_DIRECTORY)); | 688 type == storage::FileSystemContext::RESOLVED_ENTRY_DIRECTORY)); |
698 } else { | 689 } else { |
699 Send(new FileSystemMsg_DidFail(request_id, result)); | 690 Send(new FileSystemMsg_DidFail(request_id, result)); |
700 } | 691 } |
701 // For ResolveURL we do not create a new operation, so no unregister here. | 692 // For ResolveURL we do not create a new operation, so no unregister here. |
702 } | 693 } |
703 | 694 |
704 void FileAPIMessageFilter::DidDeleteFileSystem( | |
705 int request_id, | |
706 base::File::Error result) { | |
707 if (result == base::File::FILE_OK) | |
708 Send(new FileSystemMsg_DidSucceed(request_id)); | |
709 else | |
710 Send(new FileSystemMsg_DidFail(request_id, result)); | |
711 // For DeleteFileSystem we do not create a new operation, | |
712 // so no unregister here. | |
713 } | |
714 | |
715 void FileAPIMessageFilter::DidCreateSnapshot( | 695 void FileAPIMessageFilter::DidCreateSnapshot( |
716 int request_id, | 696 int request_id, |
717 const storage::FileSystemURL& url, | 697 const storage::FileSystemURL& url, |
718 base::File::Error result, | 698 base::File::Error result, |
719 const base::File::Info& info, | 699 const base::File::Info& info, |
720 const base::FilePath& platform_path, | 700 const base::FilePath& platform_path, |
721 const scoped_refptr<storage::ShareableFileReference>& /* unused */) { | 701 const scoped_refptr<storage::ShareableFileReference>& /* unused */) { |
722 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 702 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
723 operations_.erase(request_id); | 703 operations_.erase(request_id); |
724 | 704 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 } | 760 } |
781 | 761 |
782 return true; | 762 return true; |
783 } | 763 } |
784 | 764 |
785 scoped_refptr<Stream> FileAPIMessageFilter::GetStreamForURL(const GURL& url) { | 765 scoped_refptr<Stream> FileAPIMessageFilter::GetStreamForURL(const GURL& url) { |
786 return stream_context_->registry()->GetStream(url); | 766 return stream_context_->registry()->GetStream(url); |
787 } | 767 } |
788 | 768 |
789 } // namespace content | 769 } // namespace content |
OLD | NEW |