| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/quota/mock_quota_manager.h" | 5 #include "webkit/quota/mock_quota_manager.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 14 #include "webkit/quota/quota_client.h" | 14 #include "webkit/quota/quota_client.h" |
| 15 #include "webkit/quota/quota_manager.h" | 15 #include "webkit/quota/quota_manager.h" |
| 16 #include "webkit/quota/quota_task.h" | 16 #include "webkit/quota/quota_task.h" |
| 17 #include "webkit/quota/quota_types.h" | 17 #include "webkit/quota/quota_types.h" |
| 18 | 18 |
| 19 namespace quota { | 19 namespace quota { |
| 20 | 20 |
| 21 class MockQuotaManager::GetModifiedSinceTask : public QuotaThreadTask { | 21 class MockQuotaManager::GetModifiedSinceTask : public QuotaThreadTask { |
| 22 public: | 22 public: |
| 23 GetModifiedSinceTask(MockQuotaManager* manager, | 23 GetModifiedSinceTask(MockQuotaManager* manager, |
| 24 const std::set<GURL>& origins, | 24 const std::set<GURL>& origins, |
| 25 StorageType type, | 25 StorageType type, |
| 26 const GetOriginsCallback& callback) | 26 const GetOriginsCallback& callback) |
| 27 : QuotaThreadTask(manager, manager->io_thread_), | 27 : QuotaThreadTask(manager, manager->io_thread_), |
| 28 origins_(origins), | 28 origins_(origins), |
| 29 type_(type), | 29 type_(type), |
| 30 callback_(callback) {} | 30 callback_(callback) { |
| 31 } |
| 31 | 32 |
| 32 protected: | 33 protected: |
| 34 virtual ~GetModifiedSinceTask() {} |
| 35 |
| 36 // QuotaThreadTask: |
| 33 virtual void RunOnTargetThread() OVERRIDE {} | 37 virtual void RunOnTargetThread() OVERRIDE {} |
| 34 | 38 |
| 35 virtual void Completed() OVERRIDE { | 39 virtual void Completed() OVERRIDE { |
| 36 callback_.Run(origins_, type_); | 40 callback_.Run(origins_, type_); |
| 37 } | 41 } |
| 38 | 42 |
| 39 virtual void Aborted() OVERRIDE { | 43 virtual void Aborted() OVERRIDE { |
| 40 callback_.Run(std::set<GURL>(), type_); | 44 callback_.Run(std::set<GURL>(), type_); |
| 41 } | 45 } |
| 42 | 46 |
| 43 private: | 47 private: |
| 44 std::set<GURL> origins_; | 48 std::set<GURL> origins_; |
| 45 StorageType type_; | 49 StorageType type_; |
| 46 GetOriginsCallback callback_; | 50 GetOriginsCallback callback_; |
| 47 | 51 |
| 48 DISALLOW_COPY_AND_ASSIGN(GetModifiedSinceTask); | 52 DISALLOW_COPY_AND_ASSIGN(GetModifiedSinceTask); |
| 49 }; | 53 }; |
| 50 | 54 |
| 51 class MockQuotaManager::DeleteOriginDataTask : public QuotaThreadTask { | 55 class MockQuotaManager::DeleteOriginDataTask : public QuotaThreadTask { |
| 52 public: | 56 public: |
| 53 DeleteOriginDataTask(MockQuotaManager* manager, | 57 DeleteOriginDataTask(MockQuotaManager* manager, |
| 54 const StatusCallback& callback) | 58 const StatusCallback& callback) |
| 55 : QuotaThreadTask(manager, manager->io_thread_), | 59 : QuotaThreadTask(manager, manager->io_thread_), |
| 56 callback_(callback) {} | 60 callback_(callback) { |
| 61 } |
| 57 | 62 |
| 58 protected: | 63 protected: |
| 64 virtual ~DeleteOriginDataTask() {} |
| 65 |
| 66 // QuotaThreadTask: |
| 59 virtual void RunOnTargetThread() OVERRIDE {} | 67 virtual void RunOnTargetThread() OVERRIDE {} |
| 60 | 68 |
| 61 virtual void Completed() OVERRIDE { | 69 virtual void Completed() OVERRIDE { |
| 62 callback_.Run(quota::kQuotaStatusOk); | 70 callback_.Run(quota::kQuotaStatusOk); |
| 63 } | 71 } |
| 64 | 72 |
| 65 virtual void Aborted() OVERRIDE { | 73 virtual void Aborted() OVERRIDE { |
| 66 callback_.Run(quota::kQuotaErrorAbort); | 74 callback_.Run(quota::kQuotaErrorAbort); |
| 67 } | 75 } |
| 68 | 76 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 88 MockQuotaManager::MockQuotaManager( | 96 MockQuotaManager::MockQuotaManager( |
| 89 bool is_incognito, | 97 bool is_incognito, |
| 90 const FilePath& profile_path, | 98 const FilePath& profile_path, |
| 91 base::MessageLoopProxy* io_thread, | 99 base::MessageLoopProxy* io_thread, |
| 92 base::MessageLoopProxy* db_thread, | 100 base::MessageLoopProxy* db_thread, |
| 93 SpecialStoragePolicy* special_storage_policy) | 101 SpecialStoragePolicy* special_storage_policy) |
| 94 : QuotaManager(is_incognito, profile_path, io_thread, db_thread, | 102 : QuotaManager(is_incognito, profile_path, io_thread, db_thread, |
| 95 special_storage_policy) { | 103 special_storage_policy) { |
| 96 } | 104 } |
| 97 | 105 |
| 98 MockQuotaManager::~MockQuotaManager() {} | |
| 99 | |
| 100 bool MockQuotaManager::AddOrigin( | 106 bool MockQuotaManager::AddOrigin( |
| 101 const GURL& origin, | 107 const GURL& origin, |
| 102 StorageType type, | 108 StorageType type, |
| 103 int quota_client_mask, | 109 int quota_client_mask, |
| 104 base::Time modified) { | 110 base::Time modified) { |
| 105 origins_.push_back(OriginInfo(origin, type, quota_client_mask, modified)); | 111 origins_.push_back(OriginInfo(origin, type, quota_client_mask, modified)); |
| 106 return true; | 112 return true; |
| 107 } | 113 } |
| 108 | 114 |
| 109 bool MockQuotaManager::OriginHasData( | 115 bool MockQuotaManager::OriginHasData( |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 // Modify the mask: if it's 0 after "deletion", remove the origin. | 154 // Modify the mask: if it's 0 after "deletion", remove the origin. |
| 149 current->quota_client_mask &= ~quota_client_mask; | 155 current->quota_client_mask &= ~quota_client_mask; |
| 150 if (current->quota_client_mask == 0) | 156 if (current->quota_client_mask == 0) |
| 151 origins_.erase(current); | 157 origins_.erase(current); |
| 152 break; | 158 break; |
| 153 } | 159 } |
| 154 } | 160 } |
| 155 make_scoped_refptr(new DeleteOriginDataTask(this, callback))->Start(); | 161 make_scoped_refptr(new DeleteOriginDataTask(this, callback))->Start(); |
| 156 } | 162 } |
| 157 | 163 |
| 164 MockQuotaManager::~MockQuotaManager() {} |
| 165 |
| 158 } // namespace quota | 166 } // namespace quota |
| OLD | NEW |