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

Side by Side Diff: content/browser/indexed_db/indexed_db_database_unittest.cc

Issue 18075008: IndexedDB: Switch key/value handling from vector<char> to std::string (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove C++11ism Created 7 years, 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 <gtest/gtest.h>
8
9 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
10 #include "base/logging.h" 8 #include "base/logging.h"
11 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
12 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
13 #include "content/browser/indexed_db/indexed_db.h" 11 #include "content/browser/indexed_db/indexed_db.h"
14 #include "content/browser/indexed_db/indexed_db_backing_store.h" 12 #include "content/browser/indexed_db/indexed_db_backing_store.h"
15 #include "content/browser/indexed_db/indexed_db_callbacks.h" 13 #include "content/browser/indexed_db/indexed_db_callbacks.h"
16 #include "content/browser/indexed_db/indexed_db_connection.h" 14 #include "content/browser/indexed_db/indexed_db_connection.h"
17 #include "content/browser/indexed_db/indexed_db_cursor.h" 15 #include "content/browser/indexed_db/indexed_db_cursor.h"
18 #include "content/browser/indexed_db/indexed_db_database.h" 16 #include "content/browser/indexed_db/indexed_db_database.h"
19 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" 17 #include "content/browser/indexed_db/indexed_db_database_callbacks.h"
20 #include "content/browser/indexed_db/indexed_db_factory.h" 18 #include "content/browser/indexed_db/indexed_db_factory.h"
21 #include "content/browser/indexed_db/indexed_db_fake_backing_store.h" 19 #include "content/browser/indexed_db/indexed_db_fake_backing_store.h"
22 #include "content/browser/indexed_db/indexed_db_transaction.h" 20 #include "content/browser/indexed_db/indexed_db_transaction.h"
21 #include "testing/gtest/include/gtest/gtest.h"
23 22
24 namespace content { 23 namespace content {
25 24
26 TEST(IndexedDBDatabaseTest, BackingStoreRetention) { 25 TEST(IndexedDBDatabaseTest, BackingStoreRetention) {
27 scoped_refptr<IndexedDBFakeBackingStore> backing_store = 26 scoped_refptr<IndexedDBFakeBackingStore> backing_store =
28 new IndexedDBFakeBackingStore(); 27 new IndexedDBFakeBackingStore();
29 EXPECT_TRUE(backing_store->HasOneRef()); 28 EXPECT_TRUE(backing_store->HasOneRef());
30 29
31 IndexedDBFactory* factory = 0; 30 IndexedDBFactory* factory = 0;
32 scoped_refptr<IndexedDBDatabase> db = IndexedDBDatabase::Create( 31 scoped_refptr<IndexedDBDatabase> db = IndexedDBDatabase::Create(
33 ASCIIToUTF16("db"), backing_store, factory, ASCIIToUTF16("uniqueid")); 32 ASCIIToUTF16("db"), backing_store, factory, ASCIIToUTF16("uniqueid"));
34 EXPECT_FALSE(backing_store->HasOneRef()); // local and db 33 EXPECT_FALSE(backing_store->HasOneRef()); // local and db
35 db = NULL; 34 db = NULL;
36 EXPECT_TRUE(backing_store->HasOneRef()); // local 35 EXPECT_TRUE(backing_store->HasOneRef()); // local
37 } 36 }
38 37
39 class MockIDBCallbacks : public IndexedDBCallbacks { 38 class MockIDBCallbacks : public IndexedDBCallbacks {
40 public: 39 public:
41 static scoped_refptr<MockIDBCallbacks> Create() { 40 static scoped_refptr<MockIDBCallbacks> Create() {
42 return make_scoped_refptr(new MockIDBCallbacks()); 41 return make_scoped_refptr(new MockIDBCallbacks());
43 } 42 }
44 virtual void OnError(const IndexedDBDatabaseError& error) OVERRIDE {} 43 virtual void OnError(const IndexedDBDatabaseError& error) OVERRIDE {}
45 virtual void OnSuccess(const std::vector<string16>& value) OVERRIDE {} 44 virtual void OnSuccess(const std::vector<string16>& value) OVERRIDE {}
46 virtual void OnSuccess(scoped_refptr<IndexedDBCursor> cursor, 45 virtual void OnSuccess(scoped_refptr<IndexedDBCursor> cursor,
47 const IndexedDBKey& key, 46 const IndexedDBKey& key,
48 const IndexedDBKey& primary_key, 47 const IndexedDBKey& primary_key,
49 std::vector<char>* value) OVERRIDE {} 48 std::string* value) OVERRIDE {}
50 virtual void OnSuccess(scoped_ptr<IndexedDBConnection> connection, 49 virtual void OnSuccess(scoped_ptr<IndexedDBConnection> connection,
51 const IndexedDBDatabaseMetadata& metadata) OVERRIDE { 50 const IndexedDBDatabaseMetadata& metadata) OVERRIDE {
52 connection_ = connection.Pass(); 51 connection_ = connection.Pass();
53 } 52 }
54 virtual void OnSuccess(const IndexedDBKey& key) OVERRIDE {} 53 virtual void OnSuccess(const IndexedDBKey& key) OVERRIDE {}
55 virtual void OnSuccess(std::vector<char>* value) OVERRIDE {} 54 virtual void OnSuccess(std::string* value) OVERRIDE {}
56 virtual void OnSuccess(std::vector<char>* value, 55 virtual void OnSuccess(std::string* value,
57 const IndexedDBKey& key, 56 const IndexedDBKey& key,
58 const IndexedDBKeyPath& key_path) OVERRIDE {} 57 const IndexedDBKeyPath& key_path) OVERRIDE {}
59 virtual void OnSuccess(int64 value) OVERRIDE {} 58 virtual void OnSuccess(int64 value) OVERRIDE {}
60 virtual void OnSuccess() OVERRIDE {} 59 virtual void OnSuccess() OVERRIDE {}
61 virtual void OnSuccess(const IndexedDBKey& key, 60 virtual void OnSuccess(const IndexedDBKey& key,
62 const IndexedDBKey& primary_key, 61 const IndexedDBKey& primary_key,
63 std::vector<char>* value) OVERRIDE {} 62 std::string* value) OVERRIDE {}
64 virtual void OnSuccessWithPrefetch( 63 virtual void OnSuccessWithPrefetch(
65 const std::vector<IndexedDBKey>& keys, 64 const std::vector<IndexedDBKey>& keys,
66 const std::vector<IndexedDBKey>& primary_keys, 65 const std::vector<IndexedDBKey>& primary_keys,
67 const std::vector<std::vector<char> >& values) OVERRIDE {} 66 const std::vector<std::string>& values) OVERRIDE {}
68 67
69 IndexedDBConnection* connection() { return connection_.get(); } 68 IndexedDBConnection* connection() { return connection_.get(); }
70 69
71 private: 70 private:
72 virtual ~MockIDBCallbacks() { EXPECT_TRUE(connection_); } 71 virtual ~MockIDBCallbacks() { EXPECT_TRUE(connection_); }
73 MockIDBCallbacks() : IndexedDBCallbacks(NULL, 0, 0) {} 72 MockIDBCallbacks() : IndexedDBCallbacks(NULL, 0, 0) {}
74 scoped_ptr<IndexedDBConnection> connection_; 73 scoped_ptr<IndexedDBConnection> connection_;
75 }; 74 };
76 75
77 class FakeIDBDatabaseCallbacks : public IndexedDBDatabaseCallbacks { 76 class FakeIDBDatabaseCallbacks : public IndexedDBDatabaseCallbacks {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 request->connection(), 182 request->connection(),
184 scope, 183 scope,
185 indexed_db::TRANSACTION_READ_ONLY); 184 indexed_db::TRANSACTION_READ_ONLY);
186 185
187 request->connection()->ForceClose(); 186 request->connection()->ForceClose();
188 187
189 EXPECT_TRUE(backing_store->HasOneRef()); // local 188 EXPECT_TRUE(backing_store->HasOneRef()); // local
190 } 189 }
191 190
192 } // namespace content 191 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_database.cc ('k') | content/browser/indexed_db/indexed_db_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698