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/worker/worker_webkitclient_impl.h" | 5 #include "chrome/worker/worker_webkitclient_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/common/database_util.h" | 9 #include "chrome/common/database_util.h" |
10 #include "chrome/common/file_system/webfilesystem_impl.h" | 10 #include "chrome/common/file_system/webfilesystem_impl.h" |
| 11 #include "chrome/common/file_utilities_messages.h" |
11 #include "chrome/common/render_messages.h" | 12 #include "chrome/common/render_messages.h" |
12 #include "chrome/common/render_messages_params.h" | 13 #include "chrome/common/render_messages_params.h" |
| 14 #include "chrome/common/mime_registry_messages.h" |
13 #include "chrome/common/webblobregistry_impl.h" | 15 #include "chrome/common/webblobregistry_impl.h" |
14 #include "chrome/common/webmessageportchannel_impl.h" | 16 #include "chrome/common/webmessageportchannel_impl.h" |
15 #include "chrome/worker/worker_thread.h" | 17 #include "chrome/worker/worker_thread.h" |
16 #include "ipc/ipc_sync_message_filter.h" | 18 #include "ipc/ipc_sync_message_filter.h" |
17 #include "third_party/WebKit/WebKit/chromium/public/WebBlobRegistry.h" | 19 #include "third_party/WebKit/WebKit/chromium/public/WebBlobRegistry.h" |
18 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" | 20 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" |
19 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" | 21 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" |
20 #include "webkit/glue/webfileutilities_impl.h" | 22 #include "webkit/glue/webfileutilities_impl.h" |
21 #include "webkit/glue/webkit_glue.h" | 23 #include "webkit/glue/webkit_glue.h" |
22 | 24 |
(...skipping 25 matching lines...) Expand all Loading... |
48 if (worker_thread) | 50 if (worker_thread) |
49 return worker_thread->Send(msg); | 51 return worker_thread->Send(msg); |
50 | 52 |
51 scoped_refptr<IPC::SyncMessageFilter> sync_msg_filter( | 53 scoped_refptr<IPC::SyncMessageFilter> sync_msg_filter( |
52 ChildThread::current()->sync_message_filter()); | 54 ChildThread::current()->sync_message_filter()); |
53 return sync_msg_filter->Send(msg); | 55 return sync_msg_filter->Send(msg); |
54 } | 56 } |
55 | 57 |
56 bool WorkerWebKitClientImpl::FileUtilities::getFileSize(const WebString& path, | 58 bool WorkerWebKitClientImpl::FileUtilities::getFileSize(const WebString& path, |
57 long long& result) { | 59 long long& result) { |
58 if (SendSyncMessageFromAnyThread(new ViewHostMsg_GetFileSize( | 60 if (SendSyncMessageFromAnyThread(new FileUtilitiesMsg_GetFileSize( |
59 webkit_glue::WebStringToFilePath(path), | 61 webkit_glue::WebStringToFilePath(path), |
60 reinterpret_cast<int64*>(&result)))) { | 62 reinterpret_cast<int64*>(&result)))) { |
61 return result >= 0; | 63 return result >= 0; |
62 } | 64 } |
63 | 65 |
64 result = -1; | 66 result = -1; |
65 return false; | 67 return false; |
66 } | 68 } |
67 | 69 |
68 bool WorkerWebKitClientImpl::FileUtilities::getFileModificationTime( | 70 bool WorkerWebKitClientImpl::FileUtilities::getFileModificationTime( |
69 const WebString& path, | 71 const WebString& path, |
70 double& result) { | 72 double& result) { |
71 base::Time time; | 73 base::Time time; |
72 if (SendSyncMessageFromAnyThread(new ViewHostMsg_GetFileModificationTime( | 74 if (SendSyncMessageFromAnyThread(new FileUtilitiesMsg_GetFileModificationTime( |
73 webkit_glue::WebStringToFilePath(path), &time))) { | 75 webkit_glue::WebStringToFilePath(path), &time))) { |
74 result = time.ToDoubleT(); | 76 result = time.ToDoubleT(); |
75 return !time.is_null(); | 77 return !time.is_null(); |
76 } | 78 } |
77 | 79 |
78 result = 0; | 80 result = 0; |
79 return false; | 81 return false; |
80 } | 82 } |
81 | 83 |
82 //------------------------------------------------------------------------------ | 84 //------------------------------------------------------------------------------ |
83 | 85 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 223 |
222 WebMimeRegistry::SupportsType WorkerWebKitClientImpl::supportsNonImageMIMEType( | 224 WebMimeRegistry::SupportsType WorkerWebKitClientImpl::supportsNonImageMIMEType( |
223 const WebString&) { | 225 const WebString&) { |
224 NOTREACHED(); | 226 NOTREACHED(); |
225 return WebMimeRegistry::IsSupported; | 227 return WebMimeRegistry::IsSupported; |
226 } | 228 } |
227 | 229 |
228 WebString WorkerWebKitClientImpl::mimeTypeForExtension( | 230 WebString WorkerWebKitClientImpl::mimeTypeForExtension( |
229 const WebString& file_extension) { | 231 const WebString& file_extension) { |
230 std::string mime_type; | 232 std::string mime_type; |
231 SendSyncMessageFromAnyThread(new ViewHostMsg_GetMimeTypeFromExtension( | 233 SendSyncMessageFromAnyThread(new MimeRegistryMsg_GetMimeTypeFromExtension( |
232 webkit_glue::WebStringToFilePathString(file_extension), &mime_type)); | 234 webkit_glue::WebStringToFilePathString(file_extension), &mime_type)); |
233 return ASCIIToUTF16(mime_type); | 235 return ASCIIToUTF16(mime_type); |
234 } | 236 } |
235 | 237 |
236 WebString WorkerWebKitClientImpl::mimeTypeFromFile( | 238 WebString WorkerWebKitClientImpl::mimeTypeFromFile( |
237 const WebString& file_path) { | 239 const WebString& file_path) { |
238 std::string mime_type; | 240 std::string mime_type; |
239 SendSyncMessageFromAnyThread(new ViewHostMsg_GetMimeTypeFromFile( | 241 SendSyncMessageFromAnyThread(new MimeRegistryMsg_GetMimeTypeFromFile( |
240 FilePath(webkit_glue::WebStringToFilePathString(file_path)), | 242 FilePath(webkit_glue::WebStringToFilePathString(file_path)), |
241 &mime_type)); | 243 &mime_type)); |
242 return ASCIIToUTF16(mime_type); | 244 return ASCIIToUTF16(mime_type); |
243 } | 245 } |
244 | 246 |
245 WebString WorkerWebKitClientImpl::preferredExtensionForMIMEType( | 247 WebString WorkerWebKitClientImpl::preferredExtensionForMIMEType( |
246 const WebString& mime_type) { | 248 const WebString& mime_type) { |
247 FilePath::StringType file_extension; | 249 FilePath::StringType file_extension; |
248 SendSyncMessageFromAnyThread( | 250 SendSyncMessageFromAnyThread( |
249 new ViewHostMsg_GetPreferredExtensionForMimeType(UTF16ToASCII(mime_type), | 251 new MimeRegistryMsg_GetPreferredExtensionForMimeType( |
250 &file_extension)); | 252 UTF16ToASCII(mime_type), &file_extension)); |
251 return webkit_glue::FilePathStringToWebString(file_extension); | 253 return webkit_glue::FilePathStringToWebString(file_extension); |
252 } | 254 } |
253 | 255 |
254 WebBlobRegistry* WorkerWebKitClientImpl::blobRegistry() { | 256 WebBlobRegistry* WorkerWebKitClientImpl::blobRegistry() { |
255 if (!blob_registry_.get()) | 257 if (!blob_registry_.get()) |
256 blob_registry_.reset(new WebBlobRegistryImpl(WorkerThread::current())); | 258 blob_registry_.reset(new WebBlobRegistryImpl(WorkerThread::current())); |
257 return blob_registry_.get(); | 259 return blob_registry_.get(); |
258 } | 260 } |
OLD | NEW |