OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_INDEXED_DB_MOCK_CALLBACK_FACTORY_H_ |
| 6 #define CONTENT_BROWSER_INDEXED_DB_MOCK_CALLBACK_FACTORY_H_ |
| 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "base/memory/weak_ptr.h" |
| 12 #include "content/browser/indexed_db/indexed_db_callbacks.h" |
| 13 |
| 14 namespace content { |
| 15 |
| 16 class IndexedDBConnection; |
| 17 class IndexedDBDatabaseError; |
| 18 struct IndexedDBDatabaseMetadata; |
| 19 |
| 20 class MockCallbackFactory { |
| 21 public: |
| 22 MockCallbackFactory(); |
| 23 ~MockCallbackFactory(); |
| 24 |
| 25 DeleteResultCallback CreateDeleteCallback(); |
| 26 OpenResultCallback CreateOpenCallback(); |
| 27 |
| 28 IndexedDBConnection* connection() const { return connection_.get(); } |
| 29 |
| 30 bool delete_result_called() const { return delete_result_called_; } |
| 31 bool open_result_called() const { return open_result_called_; } |
| 32 |
| 33 private: |
| 34 base::WeakPtr<MockCallbackFactory> AsWeakPtr() { |
| 35 return weak_factory_.GetWeakPtr(); |
| 36 } |
| 37 |
| 38 void OnDeleteResult(int64_t version, const IndexedDBDatabaseError& error); |
| 39 void OnOpenResult(std::unique_ptr<IndexedDBConnection> connection, |
| 40 const IndexedDBDatabaseMetadata& metadata, |
| 41 const IndexedDBDatabaseError& error); |
| 42 |
| 43 std::unique_ptr<IndexedDBConnection> connection_; |
| 44 bool delete_result_called_ = false; |
| 45 bool open_result_called_ = false; |
| 46 base::WeakPtrFactory<MockCallbackFactory> weak_factory_; |
| 47 |
| 48 DISALLOW_COPY_AND_ASSIGN(MockCallbackFactory); |
| 49 }; |
| 50 |
| 51 } // namespace content |
| 52 |
| 53 #endif // CONTENT_BROWSER_INDEXED_DB_MOCK_CALLBACK_FACTORY_H_ |
OLD | NEW |