OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_database.h" | 5 #include "content/browser/indexed_db/indexed_db_database.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "content/browser/indexed_db/indexed_db_connection.h" | 16 #include "content/browser/indexed_db/indexed_db_connection.h" |
17 #include "content/browser/indexed_db/indexed_db_cursor.h" | 17 #include "content/browser/indexed_db/indexed_db_cursor.h" |
18 #include "content/browser/indexed_db/indexed_db_factory.h" | 18 #include "content/browser/indexed_db/indexed_db_factory.h" |
19 #include "content/browser/indexed_db/indexed_db_index_writer.h" | 19 #include "content/browser/indexed_db/indexed_db_index_writer.h" |
20 #include "content/browser/indexed_db/indexed_db_tracing.h" | 20 #include "content/browser/indexed_db/indexed_db_tracing.h" |
21 #include "content/browser/indexed_db/indexed_db_transaction.h" | 21 #include "content/browser/indexed_db/indexed_db_transaction.h" |
22 #include "content/common/indexed_db/indexed_db_key_path.h" | 22 #include "content/common/indexed_db/indexed_db_key_path.h" |
23 #include "content/common/indexed_db/indexed_db_key_range.h" | 23 #include "content/common/indexed_db/indexed_db_key_range.h" |
24 #include "content/public/browser/browser_thread.h" | |
25 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" | 24 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" |
26 | 25 |
27 using base::ASCIIToUTF16; | 26 using base::ASCIIToUTF16; |
28 using base::Int64ToString16; | 27 using base::Int64ToString16; |
29 using blink::WebIDBKeyTypeNumber; | 28 using blink::WebIDBKeyTypeNumber; |
30 | 29 |
31 namespace content { | 30 namespace content { |
32 | 31 |
33 // PendingOpenCall has a scoped_refptr<IndexedDBDatabaseCallbacks> because it | 32 // PendingOpenCall has a scoped_refptr<IndexedDBDatabaseCallbacks> because it |
34 // isn't a connection yet. | 33 // isn't a connection yet. |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
685 DCHECK_EQ(WebIDBKeyTypeNumber, key.type()); | 684 DCHECK_EQ(WebIDBKeyTypeNumber, key.type()); |
686 return backing_store->MaybeUpdateKeyGeneratorCurrentNumber( | 685 return backing_store->MaybeUpdateKeyGeneratorCurrentNumber( |
687 transaction->BackingStoreTransaction(), | 686 transaction->BackingStoreTransaction(), |
688 database_id, | 687 database_id, |
689 object_store_id, | 688 object_store_id, |
690 static_cast<int64>(floor(key.number())) + 1, | 689 static_cast<int64>(floor(key.number())) + 1, |
691 check_current); | 690 check_current); |
692 } | 691 } |
693 | 692 |
694 struct IndexedDBDatabase::PutOperationParams { | 693 struct IndexedDBDatabase::PutOperationParams { |
694 public: | |
Avi (use Gerrit)
2014/02/14 20:16:42
structs by default are public; this is not needed.
Lei Zhang
2014/02/14 21:11:06
Done.
| |
695 PutOperationParams() {} | 695 PutOperationParams() {} |
696 int64 object_store_id; | 696 int64 object_store_id; |
697 std::string value; | 697 std::string value; |
698 scoped_ptr<IndexedDBKey> key; | 698 scoped_ptr<IndexedDBKey> key; |
699 IndexedDBDatabase::PutMode put_mode; | 699 IndexedDBDatabase::PutMode put_mode; |
700 scoped_refptr<IndexedDBCallbacks> callbacks; | 700 scoped_refptr<IndexedDBCallbacks> callbacks; |
701 std::vector<IndexKeys> index_keys; | 701 std::vector<IndexKeys> index_keys; |
702 | 702 |
703 private: | |
703 DISALLOW_COPY_AND_ASSIGN(PutOperationParams); | 704 DISALLOW_COPY_AND_ASSIGN(PutOperationParams); |
704 }; | 705 }; |
705 | 706 |
706 void IndexedDBDatabase::Put(int64 transaction_id, | 707 void IndexedDBDatabase::Put(int64 transaction_id, |
707 int64 object_store_id, | 708 int64 object_store_id, |
708 std::string* value, | 709 std::string* value, |
709 scoped_ptr<IndexedDBKey> key, | 710 scoped_ptr<IndexedDBKey> key, |
710 PutMode put_mode, | 711 PutMode put_mode, |
711 scoped_refptr<IndexedDBCallbacks> callbacks, | 712 scoped_refptr<IndexedDBCallbacks> callbacks, |
712 const std::vector<IndexKeys>& index_keys) { | 713 const std::vector<IndexKeys>& index_keys) { |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
947 | 948 |
948 void IndexedDBDatabase::SetIndexesReadyOperation( | 949 void IndexedDBDatabase::SetIndexesReadyOperation( |
949 size_t index_count, | 950 size_t index_count, |
950 IndexedDBTransaction* transaction) { | 951 IndexedDBTransaction* transaction) { |
951 IDB_TRACE("IndexedDBDatabase::SetIndexesReadyOperation"); | 952 IDB_TRACE("IndexedDBDatabase::SetIndexesReadyOperation"); |
952 for (size_t i = 0; i < index_count; ++i) | 953 for (size_t i = 0; i < index_count; ++i) |
953 transaction->DidCompletePreemptiveEvent(); | 954 transaction->DidCompletePreemptiveEvent(); |
954 } | 955 } |
955 | 956 |
956 struct IndexedDBDatabase::OpenCursorOperationParams { | 957 struct IndexedDBDatabase::OpenCursorOperationParams { |
958 public: | |
Avi (use Gerrit)
2014/02/14 20:16:42
ditto
| |
957 OpenCursorOperationParams() {} | 959 OpenCursorOperationParams() {} |
958 int64 object_store_id; | 960 int64 object_store_id; |
959 int64 index_id; | 961 int64 index_id; |
960 scoped_ptr<IndexedDBKeyRange> key_range; | 962 scoped_ptr<IndexedDBKeyRange> key_range; |
961 indexed_db::CursorDirection direction; | 963 indexed_db::CursorDirection direction; |
962 indexed_db::CursorType cursor_type; | 964 indexed_db::CursorType cursor_type; |
963 IndexedDBDatabase::TaskType task_type; | 965 IndexedDBDatabase::TaskType task_type; |
964 scoped_refptr<IndexedDBCallbacks> callbacks; | 966 scoped_refptr<IndexedDBCallbacks> callbacks; |
965 | 967 |
968 private: | |
966 DISALLOW_COPY_AND_ASSIGN(OpenCursorOperationParams); | 969 DISALLOW_COPY_AND_ASSIGN(OpenCursorOperationParams); |
967 }; | 970 }; |
968 | 971 |
969 void IndexedDBDatabase::OpenCursor( | 972 void IndexedDBDatabase::OpenCursor( |
970 int64 transaction_id, | 973 int64 transaction_id, |
971 int64 object_store_id, | 974 int64 object_store_id, |
972 int64 index_id, | 975 int64 index_id, |
973 scoped_ptr<IndexedDBKeyRange> key_range, | 976 scoped_ptr<IndexedDBKeyRange> key_range, |
974 indexed_db::CursorDirection direction, | 977 indexed_db::CursorDirection direction, |
975 bool key_only, | 978 bool key_only, |
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1664 const base::string16& previous_version, | 1667 const base::string16& previous_version, |
1665 int64 previous_int_version, | 1668 int64 previous_int_version, |
1666 IndexedDBTransaction* transaction) { | 1669 IndexedDBTransaction* transaction) { |
1667 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); | 1670 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); |
1668 DCHECK(!transaction); | 1671 DCHECK(!transaction); |
1669 metadata_.version = previous_version; | 1672 metadata_.version = previous_version; |
1670 metadata_.int_version = previous_int_version; | 1673 metadata_.int_version = previous_int_version; |
1671 } | 1674 } |
1672 | 1675 |
1673 } // namespace content | 1676 } // namespace content |
OLD | NEW |