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/indexed_db/indexed_db_dispatcher_host.h" | 5 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/guid.h" | 10 #include "base/guid.h" |
11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
12 #include "base/process/process.h" | 12 #include "base/process/process.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "content/browser/bad_message.h" |
15 #include "content/browser/child_process_security_policy_impl.h" | 16 #include "content/browser/child_process_security_policy_impl.h" |
16 #include "content/browser/indexed_db/indexed_db_callbacks.h" | 17 #include "content/browser/indexed_db/indexed_db_callbacks.h" |
17 #include "content/browser/indexed_db/indexed_db_connection.h" | 18 #include "content/browser/indexed_db/indexed_db_connection.h" |
18 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 19 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
19 #include "content/browser/indexed_db/indexed_db_cursor.h" | 20 #include "content/browser/indexed_db/indexed_db_cursor.h" |
20 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" | 21 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" |
21 #include "content/browser/indexed_db/indexed_db_metadata.h" | 22 #include "content/browser/indexed_db/indexed_db_metadata.h" |
22 #include "content/browser/indexed_db/indexed_db_pending_connection.h" | 23 #include "content/browser/indexed_db/indexed_db_pending_connection.h" |
23 #include "content/browser/indexed_db/indexed_db_value.h" | 24 #include "content/browser/indexed_db/indexed_db_value.h" |
24 #include "content/browser/renderer_host/render_message_filter.h" | 25 #include "content/browser/renderer_host/render_message_filter.h" |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 | 408 |
408 template <typename ObjectType> | 409 template <typename ObjectType> |
409 ObjectType* IndexedDBDispatcherHost::GetOrTerminateProcess( | 410 ObjectType* IndexedDBDispatcherHost::GetOrTerminateProcess( |
410 IDMap<ObjectType, IDMapOwnPointer>* map, | 411 IDMap<ObjectType, IDMapOwnPointer>* map, |
411 int32 ipc_return_object_id) { | 412 int32 ipc_return_object_id) { |
412 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 413 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
413 ObjectType* return_object = map->Lookup(ipc_return_object_id); | 414 ObjectType* return_object = map->Lookup(ipc_return_object_id); |
414 if (!return_object) { | 415 if (!return_object) { |
415 NOTREACHED() << "Uh oh, couldn't find object with id " | 416 NOTREACHED() << "Uh oh, couldn't find object with id " |
416 << ipc_return_object_id; | 417 << ipc_return_object_id; |
417 RecordAction(base::UserMetricsAction("BadMessageTerminate_IDBMF")); | 418 bad_message::ReceivedBadMessage(this, bad_message::IDBDH_GET_OR_TERMINATE); |
418 BadMessageReceived(); | |
419 } | 419 } |
420 return return_object; | 420 return return_object; |
421 } | 421 } |
422 | 422 |
423 template <typename ObjectType> | 423 template <typename ObjectType> |
424 ObjectType* IndexedDBDispatcherHost::GetOrTerminateProcess( | 424 ObjectType* IndexedDBDispatcherHost::GetOrTerminateProcess( |
425 RefIDMap<ObjectType>* map, | 425 RefIDMap<ObjectType>* map, |
426 int32 ipc_return_object_id) { | 426 int32 ipc_return_object_id) { |
427 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 427 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
428 ObjectType* return_object = map->Lookup(ipc_return_object_id); | 428 ObjectType* return_object = map->Lookup(ipc_return_object_id); |
429 if (!return_object) { | 429 if (!return_object) { |
430 NOTREACHED() << "Uh oh, couldn't find object with id " | 430 NOTREACHED() << "Uh oh, couldn't find object with id " |
431 << ipc_return_object_id; | 431 << ipc_return_object_id; |
432 RecordAction(base::UserMetricsAction("BadMessageTerminate_IDBMF")); | 432 bad_message::ReceivedBadMessage(this, bad_message::IDBDH_GET_OR_TERMINATE); |
433 BadMessageReceived(); | |
434 } | 433 } |
435 return return_object; | 434 return return_object; |
436 } | 435 } |
437 | 436 |
438 template <typename MapType> | 437 template <typename MapType> |
439 void IndexedDBDispatcherHost::DestroyObject(MapType* map, int32 ipc_object_id) { | 438 void IndexedDBDispatcherHost::DestroyObject(MapType* map, int32 ipc_object_id) { |
440 GetOrTerminateProcess(map, ipc_object_id); | 439 GetOrTerminateProcess(map, ipc_object_id); |
441 map->Remove(ipc_object_id); | 440 map->Remove(ipc_object_id); |
442 } | 441 } |
443 | 442 |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 ChildProcessSecurityPolicyImpl* policy = | 702 ChildProcessSecurityPolicyImpl* policy = |
704 ChildProcessSecurityPolicyImpl::GetInstance(); | 703 ChildProcessSecurityPolicyImpl::GetInstance(); |
705 | 704 |
706 for (size_t i = 0; i < params.value.blob_or_file_info.size(); ++i) { | 705 for (size_t i = 0; i < params.value.blob_or_file_info.size(); ++i) { |
707 const IndexedDBMsg_BlobOrFileInfo& info = params.value.blob_or_file_info[i]; | 706 const IndexedDBMsg_BlobOrFileInfo& info = params.value.blob_or_file_info[i]; |
708 if (info.is_file) { | 707 if (info.is_file) { |
709 base::FilePath path; | 708 base::FilePath path; |
710 if (!info.file_path.empty()) { | 709 if (!info.file_path.empty()) { |
711 path = base::FilePath::FromUTF16Unsafe(info.file_path); | 710 path = base::FilePath::FromUTF16Unsafe(info.file_path); |
712 if (!policy->CanReadFile(parent_->ipc_process_id_, path)) { | 711 if (!policy->CanReadFile(parent_->ipc_process_id_, path)) { |
713 parent_->BadMessageReceived(); | 712 bad_message::ReceivedBadMessage(parent_, |
| 713 bad_message::IDBDH_CAN_READ_FILE); |
714 return; | 714 return; |
715 } | 715 } |
716 } | 716 } |
717 blob_info[i] = | 717 blob_info[i] = |
718 IndexedDBBlobInfo(info.uuid, path, info.file_name, info.mime_type); | 718 IndexedDBBlobInfo(info.uuid, path, info.file_name, info.mime_type); |
719 if (info.size != static_cast<uint64_t>(-1)) { | 719 if (info.size != static_cast<uint64_t>(-1)) { |
720 blob_info[i].set_last_modified( | 720 blob_info[i].set_last_modified( |
721 base::Time::FromDoubleT(info.last_modified)); | 721 base::Time::FromDoubleT(info.last_modified)); |
722 blob_info[i].set_size(info.size); | 722 blob_info[i].set_size(info.size); |
723 } | 723 } |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 } | 1044 } |
1045 | 1045 |
1046 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( | 1046 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( |
1047 int32 ipc_object_id) { | 1047 int32 ipc_object_id) { |
1048 DCHECK( | 1048 DCHECK( |
1049 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 1049 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
1050 parent_->DestroyObject(&map_, ipc_object_id); | 1050 parent_->DestroyObject(&map_, ipc_object_id); |
1051 } | 1051 } |
1052 | 1052 |
1053 } // namespace content | 1053 } // namespace content |
OLD | NEW |