| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_MOCK_BROWSING_DATA_DATABASE_HELPER_H_ | 5 #ifndef CHROME_BROWSER_MOCK_BROWSING_DATA_DATABASE_HELPER_H_ |
| 6 #define CHROME_BROWSER_MOCK_BROWSING_DATA_DATABASE_HELPER_H_ | 6 #define CHROME_BROWSER_MOCK_BROWSING_DATA_DATABASE_HELPER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <list> |
| 9 #include <map> | 10 #include <map> |
| 10 #include <vector> | |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 | 13 |
| 14 #include "chrome/browser/browsing_data_database_helper.h" | 14 #include "chrome/browser/browsing_data_database_helper.h" |
| 15 | 15 |
| 16 // Mock for BrowsingDataDatabaseHelper. | 16 // Mock for BrowsingDataDatabaseHelper. |
| 17 // Use AddDatabaseSamples() or add directly to response_ vector, then call | 17 // Use AddDatabaseSamples() or add directly to response_ list, then call |
| 18 // Notify(). | 18 // Notify(). |
| 19 class MockBrowsingDataDatabaseHelper : public BrowsingDataDatabaseHelper { | 19 class MockBrowsingDataDatabaseHelper : public BrowsingDataDatabaseHelper { |
| 20 public: | 20 public: |
| 21 explicit MockBrowsingDataDatabaseHelper(Profile* profile); | 21 explicit MockBrowsingDataDatabaseHelper(Profile* profile); |
| 22 | 22 |
| 23 virtual void StartFetching( | 23 virtual void StartFetching( |
| 24 Callback1<const std::vector<DatabaseInfo>& >::Type* callback); | 24 Callback1<const std::list<DatabaseInfo>& >::Type* callback); |
| 25 | 25 |
| 26 virtual void CancelNotification(); | 26 virtual void CancelNotification(); |
| 27 | 27 |
| 28 virtual void DeleteDatabase(const std::string& origin, | 28 virtual void DeleteDatabase(const std::string& origin, |
| 29 const std::string& name); | 29 const std::string& name); |
| 30 | 30 |
| 31 // Adds some DatabaseInfo samples. | 31 // Adds some DatabaseInfo samples. |
| 32 void AddDatabaseSamples(); | 32 void AddDatabaseSamples(); |
| 33 | 33 |
| 34 // Notifies the callback. | 34 // Notifies the callback. |
| 35 void Notify(); | 35 void Notify(); |
| 36 | 36 |
| 37 // Marks all databases as existing. | 37 // Marks all databases as existing. |
| 38 void Reset(); | 38 void Reset(); |
| 39 | 39 |
| 40 // Returns true if all databases since the last Reset() invokation were | 40 // Returns true if all databases since the last Reset() invokation were |
| 41 // deleted. | 41 // deleted. |
| 42 bool AllDeleted(); | 42 bool AllDeleted(); |
| 43 | 43 |
| 44 std::string last_deleted_origin_; | 44 std::string last_deleted_origin_; |
| 45 | 45 |
| 46 std::string last_deleted_db_; | 46 std::string last_deleted_db_; |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 virtual ~MockBrowsingDataDatabaseHelper(); | 49 virtual ~MockBrowsingDataDatabaseHelper(); |
| 50 | 50 |
| 51 Profile* profile_; | 51 Profile* profile_; |
| 52 | 52 |
| 53 scoped_ptr<Callback1<const std::vector<DatabaseInfo>& >::Type > | 53 scoped_ptr<Callback1<const std::list<DatabaseInfo>& >::Type > |
| 54 callback_; | 54 callback_; |
| 55 | 55 |
| 56 // Stores which databases exist. | 56 // Stores which databases exist. |
| 57 std::map<const std::string, bool> databases_; | 57 std::map<const std::string, bool> databases_; |
| 58 | 58 |
| 59 std::vector<DatabaseInfo> response_; | 59 std::list<DatabaseInfo> response_; |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 #endif // CHROME_BROWSER_MOCK_BROWSING_DATA_DATABASE_HELPER_H_ | 62 #endif // CHROME_BROWSER_MOCK_BROWSING_DATA_DATABASE_HELPER_H_ |
| OLD | NEW |