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

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

Issue 417573004: indexeddb: Removed use of dangling ptr in writeBlobToFileOnIOThread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also scoped LocalWriteClosure::task_runner_ Created 6 years, 4 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
OLDNEW
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_backing_store.h" 5 #include "content/browser/indexed_db/indexed_db_backing_store.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/sequenced_task_runner.h"
12 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
13 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
14 #include "base/task_runner.h"
15 #include "base/test/test_simple_task_runner.h" 15 #include "base/test/test_simple_task_runner.h"
16 #include "content/browser/indexed_db/indexed_db_context_impl.h" 16 #include "content/browser/indexed_db/indexed_db_context_impl.h"
17 #include "content/browser/indexed_db/indexed_db_factory_impl.h" 17 #include "content/browser/indexed_db/indexed_db_factory_impl.h"
18 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h" 18 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h"
19 #include "content/browser/indexed_db/indexed_db_value.h" 19 #include "content/browser/indexed_db/indexed_db_value.h"
20 #include "content/browser/indexed_db/leveldb/leveldb_factory.h" 20 #include "content/browser/indexed_db/leveldb/leveldb_factory.h"
21 #include "content/public/test/mock_special_storage_policy.h" 21 #include "content/public/test/mock_special_storage_policy.h"
22 #include "net/url_request/url_request_test_util.h" 22 #include "net/url_request/url_request_test_util.h"
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 #include "third_party/WebKit/public/platform/WebIDBTypes.h" 24 #include "third_party/WebKit/public/platform/WebIDBTypes.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 }; 59 };
60 60
61 class TestableIndexedDBBackingStore : public IndexedDBBackingStore { 61 class TestableIndexedDBBackingStore : public IndexedDBBackingStore {
62 public: 62 public:
63 static scoped_refptr<TestableIndexedDBBackingStore> Open( 63 static scoped_refptr<TestableIndexedDBBackingStore> Open(
64 IndexedDBFactory* indexed_db_factory, 64 IndexedDBFactory* indexed_db_factory,
65 const GURL& origin_url, 65 const GURL& origin_url,
66 const base::FilePath& path_base, 66 const base::FilePath& path_base,
67 net::URLRequestContext* request_context, 67 net::URLRequestContext* request_context,
68 LevelDBFactory* leveldb_factory, 68 LevelDBFactory* leveldb_factory,
69 base::TaskRunner* task_runner, 69 base::SequencedTaskRunner* task_runner,
70 leveldb::Status* status) { 70 leveldb::Status* status) {
71 DCHECK(!path_base.empty()); 71 DCHECK(!path_base.empty());
72 72
73 scoped_ptr<LevelDBComparator> comparator(new Comparator()); 73 scoped_ptr<LevelDBComparator> comparator(new Comparator());
74 74
75 if (!base::CreateDirectory(path_base)) { 75 if (!base::CreateDirectory(path_base)) {
76 *status = leveldb::Status::IOError("Unable to create base dir"); 76 *status = leveldb::Status::IOError("Unable to create base dir");
77 return scoped_refptr<TestableIndexedDBBackingStore>(); 77 return scoped_refptr<TestableIndexedDBBackingStore>();
78 } 78 }
79 79
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 CleanPrimaryJournalIgnoreReturn(); 150 CleanPrimaryJournalIgnoreReturn();
151 } 151 }
152 152
153 private: 153 private:
154 TestableIndexedDBBackingStore(IndexedDBFactory* indexed_db_factory, 154 TestableIndexedDBBackingStore(IndexedDBFactory* indexed_db_factory,
155 const GURL& origin_url, 155 const GURL& origin_url,
156 const base::FilePath& blob_path, 156 const base::FilePath& blob_path,
157 net::URLRequestContext* request_context, 157 net::URLRequestContext* request_context,
158 scoped_ptr<LevelDBDatabase> db, 158 scoped_ptr<LevelDBDatabase> db,
159 scoped_ptr<LevelDBComparator> comparator, 159 scoped_ptr<LevelDBComparator> comparator,
160 base::TaskRunner* task_runner) 160 base::SequencedTaskRunner* task_runner)
161 : IndexedDBBackingStore(indexed_db_factory, 161 : IndexedDBBackingStore(indexed_db_factory,
162 origin_url, 162 origin_url,
163 blob_path, 163 blob_path,
164 request_context, 164 request_context,
165 db.Pass(), 165 db.Pass(),
166 comparator.Pass(), 166 comparator.Pass(),
167 task_runner), 167 task_runner),
168 database_id_(0) {} 168 database_id_(0) {}
169 169
170 int64 database_id_; 170 int64 database_id_;
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 EXPECT_EQ(index_name, index.name); 963 EXPECT_EQ(index_name, index.name);
964 EXPECT_EQ(index_key_path, index.key_path); 964 EXPECT_EQ(index_key_path, index.key_path);
965 EXPECT_EQ(unique, index.unique); 965 EXPECT_EQ(unique, index.unique);
966 EXPECT_EQ(multi_entry, index.multi_entry); 966 EXPECT_EQ(multi_entry, index.multi_entry);
967 } 967 }
968 } 968 }
969 969
970 } // namespace 970 } // namespace
971 971
972 } // namespace content 972 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698