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

Side by Side Diff: chrome/browser/file_system/file_system_dispatcher_host.cc

Issue 4821005: Make FileSystemOperation's lifetime more explicit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: simple_file_writer fix Created 10 years 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
« no previous file with comments | « chrome/browser/file_system/file_system_dispatcher_host.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "chrome/browser/browser_thread.h" 11 #include "chrome/browser/browser_thread.h"
12 #include "chrome/browser/file_system/browser_file_system_callback_dispatcher.h"
13 #include "chrome/browser/file_system/browser_file_system_context.h" 12 #include "chrome/browser/file_system/browser_file_system_context.h"
14 #include "chrome/browser/host_content_settings_map.h" 13 #include "chrome/browser/host_content_settings_map.h"
15 #include "chrome/browser/net/chrome_url_request_context.h" 14 #include "chrome/browser/net/chrome_url_request_context.h"
16 #include "chrome/browser/profile.h" 15 #include "chrome/browser/profile.h"
17 #include "chrome/browser/renderer_host/browser_render_process_host.h" 16 #include "chrome/browser/renderer_host/browser_render_process_host.h"
18 #include "chrome/common/net/url_request_context_getter.h" 17 #include "chrome/common/net/url_request_context_getter.h"
19 #include "chrome/common/render_messages.h" 18 #include "chrome/common/render_messages.h"
20 #include "chrome/common/render_messages_params.h" 19 #include "chrome/common/render_messages_params.h"
21 #include "googleurl/src/gurl.h" 20 #include "googleurl/src/gurl.h"
22 #include "net/url_request/url_request_context.h" 21 #include "net/url_request/url_request_context.h"
22 #include "webkit/fileapi/file_system_callback_dispatcher.h"
23 #include "webkit/fileapi/file_system_operation.h" 23 #include "webkit/fileapi/file_system_operation.h"
24 #include "webkit/fileapi/file_system_path_manager.h" 24 #include "webkit/fileapi/file_system_path_manager.h"
25 #include "webkit/fileapi/file_system_quota_manager.h" 25 #include "webkit/fileapi/file_system_quota_manager.h"
26 #include "webkit/fileapi/sandboxed_file_system_operation.h" 26 #include "webkit/fileapi/sandboxed_file_system_operation.h"
27 27
28 using fileapi::FileSystemCallbackDispatcher;
28 using fileapi::FileSystemQuotaManager; 29 using fileapi::FileSystemQuotaManager;
29 using fileapi::SandboxedFileSystemOperation; 30 using fileapi::SandboxedFileSystemOperation;
30 31
32 class BrowserFileSystemCallbackDispatcher
33 : public FileSystemCallbackDispatcher {
34 public:
35 BrowserFileSystemCallbackDispatcher(
36 FileSystemDispatcherHost* dispatcher_host, int request_id)
37 : dispatcher_host_(dispatcher_host),
38 request_id_(request_id) {
39 DCHECK(dispatcher_host_);
40 }
41
42 virtual ~BrowserFileSystemCallbackDispatcher() {
43 dispatcher_host_->UnregisterOperation(request_id_);
44 }
45
46 virtual void DidSucceed() {
47 dispatcher_host_->Send(new ViewMsg_FileSystem_DidSucceed(request_id_));
48 }
49
50 virtual void DidReadMetadata(const base::PlatformFileInfo& info) {
51 dispatcher_host_->Send(new ViewMsg_FileSystem_DidReadMetadata(
52 request_id_, info));
53 }
54
55 virtual void DidReadDirectory(
56 const std::vector<base::FileUtilProxy::Entry>& entries, bool has_more) {
57 dispatcher_host_->Send(new ViewMsg_FileSystem_DidReadDirectory(
58 request_id_, entries, has_more));
59 }
60
61 virtual void DidOpenFileSystem(const std::string& name,
62 const FilePath& path) {
63 dispatcher_host_->Send(
64 new ViewMsg_OpenFileSystemRequest_Complete(
65 request_id_, !path.empty(), name, path));
66 }
67
68 virtual void DidFail(base::PlatformFileError error_code) {
69 dispatcher_host_->Send(new ViewMsg_FileSystem_DidFail(
70 request_id_, error_code));
71 }
72
73 virtual void DidWrite(int64 bytes, bool complete) {
74 dispatcher_host_->Send(new ViewMsg_FileSystem_DidWrite(
75 request_id_, bytes, complete));
76 }
77
78 private:
79 scoped_refptr<FileSystemDispatcherHost> dispatcher_host_;
80 int request_id_;
81 };
82
31 FileSystemDispatcherHost::FileSystemDispatcherHost( 83 FileSystemDispatcherHost::FileSystemDispatcherHost(
32 IPC::Message::Sender* sender, Profile* profile) 84 IPC::Message::Sender* sender, Profile* profile)
33 : message_sender_(sender), 85 : message_sender_(sender),
34 process_handle_(0), 86 process_handle_(0),
35 shutdown_(false), 87 shutdown_(false),
36 context_(profile->GetFileSystemContext()), 88 context_(profile->GetFileSystemContext()),
37 host_content_settings_map_(profile->GetHostContentSettingsMap()), 89 host_content_settings_map_(profile->GetHostContentSettingsMap()),
38 request_context_getter_(profile->GetRequestContext()) { 90 request_context_getter_(profile->GetRequestContext()) {
39 DCHECK(message_sender_); 91 DCHECK(message_sender_);
40 } 92 }
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 BrowserFileSystemCallbackDispatcher* dispatcher = 262 BrowserFileSystemCallbackDispatcher* dispatcher =
211 new BrowserFileSystemCallbackDispatcher(this, request_id); 263 new BrowserFileSystemCallbackDispatcher(this, request_id);
212 SandboxedFileSystemOperation* operation = new SandboxedFileSystemOperation( 264 SandboxedFileSystemOperation* operation = new SandboxedFileSystemOperation(
213 dispatcher, 265 dispatcher,
214 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), 266 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE),
215 context_.get()); 267 context_.get());
216 operations_.AddWithID(operation, request_id); 268 operations_.AddWithID(operation, request_id);
217 return operation; 269 return operation;
218 } 270 }
219 271
220 void FileSystemDispatcherHost::RemoveCompletedOperation(int request_id) { 272 void FileSystemDispatcherHost::UnregisterOperation(int request_id) {
221 DCHECK(operations_.Lookup(request_id)); 273 DCHECK(operations_.Lookup(request_id));
222 operations_.Remove(request_id); 274 operations_.Remove(request_id);
223 } 275 }
OLDNEW
« no previous file with comments | « chrome/browser/file_system/file_system_dispatcher_host.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698