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

Side by Side Diff: content/worker/worker_webkitplatformsupport_impl.cc

Issue 10441016: Add FileUtilities::GetFileInfo() to capture file metadata with single IPC (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
OLDNEW
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/worker/worker_webkitplatformsupport_impl.h" 5 #include "content/worker/worker_webkitplatformsupport_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/platform_file.h"
8 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
9 #include "content/common/database_util.h" 10 #include "content/common/database_util.h"
10 #include "content/common/fileapi/webblobregistry_impl.h" 11 #include "content/common/fileapi/webblobregistry_impl.h"
11 #include "content/common/fileapi/webfilesystem_impl.h" 12 #include "content/common/fileapi/webfilesystem_impl.h"
12 #include "content/common/file_utilities_messages.h" 13 #include "content/common/file_utilities_messages.h"
13 #include "content/common/indexed_db/proxy_webidbfactory_impl.h" 14 #include "content/common/indexed_db/proxy_webidbfactory_impl.h"
14 #include "content/common/mime_registry_messages.h" 15 #include "content/common/mime_registry_messages.h"
15 #include "content/common/webmessageportchannel_impl.h" 16 #include "content/common/webmessageportchannel_impl.h"
16 #include "content/worker/worker_thread.h" 17 #include "content/worker/worker_thread.h"
17 #include "ipc/ipc_sync_message_filter.h" 18 #include "ipc/ipc_sync_message_filter.h"
18 #include "net/base/mime_util.h" 19 #include "net/base/mime_util.h"
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileInfo.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebBlobRegis try.h" 21 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebBlobRegis try.h"
20 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 22 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
21 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" 23 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
22 #include "webkit/glue/webfileutilities_impl.h" 24 #include "webkit/glue/webfileutilities_impl.h"
23 #include "webkit/glue/webkit_glue.h" 25 #include "webkit/glue/webkit_glue.h"
24 26
25 using WebKit::WebBlobRegistry; 27 using WebKit::WebBlobRegistry;
26 using WebKit::WebClipboard; 28 using WebKit::WebClipboard;
29 using WebKit::WebFileInfo;
27 using WebKit::WebFileSystem; 30 using WebKit::WebFileSystem;
28 using WebKit::WebFileUtilities; 31 using WebKit::WebFileUtilities;
29 using WebKit::WebKitPlatformSupport; 32 using WebKit::WebKitPlatformSupport;
30 using WebKit::WebMessagePortChannel; 33 using WebKit::WebMessagePortChannel;
31 using WebKit::WebMimeRegistry; 34 using WebKit::WebMimeRegistry;
32 using WebKit::WebSandboxSupport; 35 using WebKit::WebSandboxSupport;
33 using WebKit::WebSharedWorkerRepository; 36 using WebKit::WebSharedWorkerRepository;
34 using WebKit::WebStorageNamespace; 37 using WebKit::WebStorageNamespace;
35 using WebKit::WebString; 38 using WebKit::WebString;
36 using WebKit::WebURL; 39 using WebKit::WebURL;
37 40
38 // TODO(kinuko): Probably this could be consolidated into 41 // TODO(kinuko): Probably this could be consolidated into
39 // RendererWebKitPlatformSupportImpl::FileUtilities. 42 // RendererWebKitPlatformSupportImpl::FileUtilities.
40 class WorkerWebKitPlatformSupportImpl::FileUtilities 43 class WorkerWebKitPlatformSupportImpl::FileUtilities
41 : public webkit_glue::WebFileUtilitiesImpl { 44 : public webkit_glue::WebFileUtilitiesImpl {
42 public: 45 public:
43 virtual bool getFileSize(const WebKit::WebString& path, long long& result); 46 virtual bool getFileSize(const WebKit::WebString& path, long long& result);
44 virtual bool getFileModificationTime(const WebKit::WebString& path, 47 virtual bool getFileModificationTime(const WebKit::WebString& path,
45 double& result); 48 double& result);
49 virtual bool getFileInfo(const WebString& path, WebFileInfo& result);
46 }; 50 };
47 51
48 static bool SendSyncMessageFromAnyThread(IPC::SyncMessage* msg) { 52 static bool SendSyncMessageFromAnyThread(IPC::SyncMessage* msg) {
49 WorkerThread* worker_thread = WorkerThread::current(); 53 WorkerThread* worker_thread = WorkerThread::current();
50 if (worker_thread) 54 if (worker_thread)
51 return worker_thread->Send(msg); 55 return worker_thread->Send(msg);
52 56
53 scoped_refptr<IPC::SyncMessageFilter> sync_msg_filter( 57 scoped_refptr<IPC::SyncMessageFilter> sync_msg_filter(
54 ChildThread::current()->sync_message_filter()); 58 ChildThread::current()->sync_message_filter());
55 return sync_msg_filter->Send(msg); 59 return sync_msg_filter->Send(msg);
(...skipping 18 matching lines...) Expand all
74 if (SendSyncMessageFromAnyThread(new FileUtilitiesMsg_GetFileModificationTime( 78 if (SendSyncMessageFromAnyThread(new FileUtilitiesMsg_GetFileModificationTime(
75 webkit_glue::WebStringToFilePath(path), &time))) { 79 webkit_glue::WebStringToFilePath(path), &time))) {
76 result = time.ToDoubleT(); 80 result = time.ToDoubleT();
77 return !time.is_null(); 81 return !time.is_null();
78 } 82 }
79 83
80 result = 0; 84 result = 0;
81 return false; 85 return false;
82 } 86 }
83 87
88 bool WorkerWebKitPlatformSupportImpl::FileUtilities::getFileInfo(
89 const WebString& path,
90 WebFileInfo& web_file_info) {
91 base::PlatformFileInfo file_info;
92 base::PlatformFileError status;
93 if (!SendSyncMessageFromAnyThread(new FileUtilitiesMsg_GetFileInfo(
94 webkit_glue::WebStringToFilePath(path), &file_info, &status)) ||
95 status != base::PLATFORM_FILE_OK) {
96 return false;
97 }
98 webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info);
99 web_file_info.platformPath = path;
100 return true;
101 }
102
84 //------------------------------------------------------------------------------ 103 //------------------------------------------------------------------------------
85 104
86 WorkerWebKitPlatformSupportImpl::WorkerWebKitPlatformSupportImpl() { 105 WorkerWebKitPlatformSupportImpl::WorkerWebKitPlatformSupportImpl() {
87 } 106 }
88 107
89 WorkerWebKitPlatformSupportImpl::~WorkerWebKitPlatformSupportImpl() { 108 WorkerWebKitPlatformSupportImpl::~WorkerWebKitPlatformSupportImpl() {
90 } 109 }
91 110
92 WebClipboard* WorkerWebKitPlatformSupportImpl::clipboard() { 111 WebClipboard* WorkerWebKitPlatformSupportImpl::clipboard() {
93 NOTREACHED(); 112 NOTREACHED();
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 new MimeRegistryMsg_GetPreferredExtensionForMimeType( 306 new MimeRegistryMsg_GetPreferredExtensionForMimeType(
288 UTF16ToASCII(mime_type), &file_extension)); 307 UTF16ToASCII(mime_type), &file_extension));
289 return webkit_glue::FilePathStringToWebString(file_extension); 308 return webkit_glue::FilePathStringToWebString(file_extension);
290 } 309 }
291 310
292 WebBlobRegistry* WorkerWebKitPlatformSupportImpl::blobRegistry() { 311 WebBlobRegistry* WorkerWebKitPlatformSupportImpl::blobRegistry() {
293 if (!blob_registry_.get()) 312 if (!blob_registry_.get())
294 blob_registry_.reset(new WebBlobRegistryImpl(WorkerThread::current())); 313 blob_registry_.reset(new WebBlobRegistryImpl(WorkerThread::current()));
295 return blob_registry_.get(); 314 return blob_registry_.get();
296 } 315 }
OLDNEW
« no previous file with comments | « content/renderer/renderer_webkitplatformsupport_impl.cc ('k') | webkit/glue/webfileutilities_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698