OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/file_system/file_system_dispatcher_host.h" | 5 #include "chrome/browser/file_system/file_system_dispatcher_host.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/thread.h" | 8 #include "base/thread.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 int request_id, | 52 int request_id, |
53 const std::string& name, | 53 const std::string& name, |
54 const FilePath& root_path, | 54 const FilePath& root_path, |
55 FileSystemDispatcherHost* dispatcher_host) | 55 FileSystemDispatcherHost* dispatcher_host) |
56 : request_id_(request_id), | 56 : request_id_(request_id), |
57 name_(name), | 57 name_(name), |
58 root_path_(root_path), | 58 root_path_(root_path), |
59 dispatcher_host_(dispatcher_host), | 59 dispatcher_host_(dispatcher_host), |
60 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 60 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
61 base::FileUtilProxy::CreateDirectory( | 61 base::FileUtilProxy::CreateDirectory( |
62 ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE), | 62 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
63 root_path_, false, true, callback_factory_.NewCallback( | 63 root_path_, false, true, callback_factory_.NewCallback( |
64 &OpenFileSystemCompletionTask::DidFinish)); | 64 &OpenFileSystemCompletionTask::DidFinish)); |
65 } | 65 } |
66 | 66 |
67 int request_id_; | 67 int request_id_; |
68 std::string name_; | 68 std::string name_; |
69 FilePath root_path_; | 69 FilePath root_path_; |
70 scoped_refptr<FileSystemDispatcherHost> dispatcher_host_; | 70 scoped_refptr<FileSystemDispatcherHost> dispatcher_host_; |
71 base::ScopedCallbackFactory<OpenFileSystemCompletionTask> callback_factory_; | 71 base::ScopedCallbackFactory<OpenFileSystemCompletionTask> callback_factory_; |
72 }; | 72 }; |
73 | 73 |
74 FileSystemDispatcherHost::FileSystemDispatcherHost( | 74 FileSystemDispatcherHost::FileSystemDispatcherHost( |
75 IPC::Message::Sender* sender, | 75 IPC::Message::Sender* sender, |
76 FileSystemHostContext* file_system_host_context, | 76 FileSystemHostContext* file_system_host_context, |
77 HostContentSettingsMap* host_content_settings_map, | 77 HostContentSettingsMap* host_content_settings_map, |
78 URLRequestContextGetter* request_context_getter) | 78 URLRequestContextGetter* request_context_getter) |
79 : message_sender_(sender), | 79 : message_sender_(sender), |
80 process_handle_(0), | 80 process_handle_(0), |
81 shutdown_(false), | 81 shutdown_(false), |
82 context_(file_system_host_context), | 82 context_(file_system_host_context), |
83 host_content_settings_map_(host_content_settings_map), | 83 host_content_settings_map_(host_content_settings_map), |
84 request_context_getter_(request_context_getter) { | 84 request_context_getter_(request_context_getter) { |
85 DCHECK(message_sender_); | 85 DCHECK(message_sender_); |
86 } | 86 } |
87 | 87 |
88 FileSystemDispatcherHost::~FileSystemDispatcherHost() { | 88 FileSystemDispatcherHost::~FileSystemDispatcherHost() { |
89 } | 89 } |
90 | 90 |
91 void FileSystemDispatcherHost::Init(base::ProcessHandle process_handle) { | 91 void FileSystemDispatcherHost::Init(base::ProcessHandle process_handle) { |
92 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 92 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
93 DCHECK(!shutdown_); | 93 DCHECK(!shutdown_); |
94 DCHECK(!process_handle_); | 94 DCHECK(!process_handle_); |
95 DCHECK(process_handle); | 95 DCHECK(process_handle); |
96 process_handle_ = process_handle; | 96 process_handle_ = process_handle; |
97 DCHECK(!request_context_.get()); | 97 DCHECK(!request_context_.get()); |
98 if (request_context_getter_.get()) | 98 if (request_context_getter_.get()) |
99 request_context_ = request_context_getter_->GetURLRequestContext(); | 99 request_context_ = request_context_getter_->GetURLRequestContext(); |
100 } | 100 } |
101 | 101 |
102 void FileSystemDispatcherHost::Shutdown() { | 102 void FileSystemDispatcherHost::Shutdown() { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 // success. | 267 // success. |
268 write->Cancel(GetNewOperation(request_id)); | 268 write->Cancel(GetNewOperation(request_id)); |
269 } else { | 269 } else { |
270 // The write already finished; report that we failed to stop it. | 270 // The write already finished; report that we failed to stop it. |
271 Send(new ViewMsg_FileSystem_DidFail( | 271 Send(new ViewMsg_FileSystem_DidFail( |
272 request_id, base::PLATFORM_FILE_ERROR_INVALID_OPERATION)); | 272 request_id, base::PLATFORM_FILE_ERROR_INVALID_OPERATION)); |
273 } | 273 } |
274 } | 274 } |
275 | 275 |
276 void FileSystemDispatcherHost::Send(IPC::Message* message) { | 276 void FileSystemDispatcherHost::Send(IPC::Message* message) { |
277 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 277 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
278 if (!shutdown_ && message_sender_) | 278 if (!shutdown_ && message_sender_) |
279 message_sender_->Send(message); | 279 message_sender_->Send(message); |
280 else | 280 else |
281 delete message; | 281 delete message; |
282 } | 282 } |
283 | 283 |
284 bool FileSystemDispatcherHost::CheckValidFileSystemPath( | 284 bool FileSystemDispatcherHost::CheckValidFileSystemPath( |
285 const FilePath& path, int request_id) { | 285 const FilePath& path, int request_id) { |
286 // We may want do more checks, but for now it just checks if the given | 286 // We may want do more checks, but for now it just checks if the given |
287 // |path| is under the valid FileSystem root path for this host context. | 287 // |path| is under the valid FileSystem root path for this host context. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 } | 321 } |
322 return true; | 322 return true; |
323 } | 323 } |
324 | 324 |
325 fileapi::FileSystemOperation* FileSystemDispatcherHost::GetNewOperation( | 325 fileapi::FileSystemOperation* FileSystemDispatcherHost::GetNewOperation( |
326 int request_id) { | 326 int request_id) { |
327 BrowserFileSystemCallbackDispatcher* dispatcher = | 327 BrowserFileSystemCallbackDispatcher* dispatcher = |
328 new BrowserFileSystemCallbackDispatcher(this, request_id); | 328 new BrowserFileSystemCallbackDispatcher(this, request_id); |
329 fileapi::FileSystemOperation* operation = new fileapi::FileSystemOperation( | 329 fileapi::FileSystemOperation* operation = new fileapi::FileSystemOperation( |
330 dispatcher, | 330 dispatcher, |
331 ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)); | 331 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); |
332 operations_.AddWithID(operation, request_id); | 332 operations_.AddWithID(operation, request_id); |
333 return operation; | 333 return operation; |
334 } | 334 } |
335 | 335 |
336 void FileSystemDispatcherHost::RemoveCompletedOperation(int request_id) { | 336 void FileSystemDispatcherHost::RemoveCompletedOperation(int request_id) { |
337 DCHECK(operations_.Lookup(request_id)); | 337 DCHECK(operations_.Lookup(request_id)); |
338 operations_.Remove(request_id); | 338 operations_.Remove(request_id); |
339 } | 339 } |
OLD | NEW |