| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/in_process_webkit/indexed_db_quota_client.h" | 5 #include "content/browser/in_process_webkit/indexed_db_quota_client.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 protected: | 81 protected: |
| 82 GetOriginsTaskBase( | 82 GetOriginsTaskBase( |
| 83 IndexedDBQuotaClient* client, | 83 IndexedDBQuotaClient* client, |
| 84 base::MessageLoopProxy* webkit_thread_message_loop) | 84 base::MessageLoopProxy* webkit_thread_message_loop) |
| 85 : HelperTask(client, webkit_thread_message_loop) { | 85 : HelperTask(client, webkit_thread_message_loop) { |
| 86 } | 86 } |
| 87 | 87 |
| 88 virtual bool ShouldAddOrigin(const GURL& origin) = 0; | 88 virtual bool ShouldAddOrigin(const GURL& origin) = 0; |
| 89 | 89 |
| 90 virtual void RunOnTargetThread() OVERRIDE { | 90 virtual void RunOnTargetThread() OVERRIDE { |
| 91 std::vector<string16> origin_identifiers; | 91 std::vector<GURL> origins; |
| 92 indexed_db_context_->GetAllOriginIdentifiers(&origin_identifiers); | 92 indexed_db_context_->GetAllOrigins(&origins); |
| 93 for (std::vector<string16>::const_iterator iter = | 93 for (std::vector<GURL>::const_iterator iter = origins.begin(); |
| 94 origin_identifiers.begin(); | 94 iter != origins.end(); ++iter) { |
| 95 iter != origin_identifiers.end(); ++iter) { | 95 if (ShouldAddOrigin(*iter)) |
| 96 GURL origin = DatabaseUtil::GetOriginFromIdentifier(*iter); | 96 origins_.insert(*iter); |
| 97 if (ShouldAddOrigin(origin)) | |
| 98 origins_.insert(origin); | |
| 99 } | 97 } |
| 100 } | 98 } |
| 101 | 99 |
| 102 std::set<GURL> origins_; | 100 std::set<GURL> origins_; |
| 103 }; | 101 }; |
| 104 | 102 |
| 105 class IndexedDBQuotaClient::GetAllOriginsTask : public GetOriginsTaskBase { | 103 class IndexedDBQuotaClient::GetAllOriginsTask : public GetOriginsTaskBase { |
| 106 public: | 104 public: |
| 107 GetAllOriginsTask( | 105 GetAllOriginsTask( |
| 108 IndexedDBQuotaClient* client, | 106 IndexedDBQuotaClient* client, |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 DCHECK(origins_for_type_callbacks_.HasCallbacks()); | 254 DCHECK(origins_for_type_callbacks_.HasCallbacks()); |
| 257 origins_for_type_callbacks_.Run(origins, type); | 255 origins_for_type_callbacks_.Run(origins, type); |
| 258 } | 256 } |
| 259 | 257 |
| 260 void IndexedDBQuotaClient::DidGetOriginsForHost( | 258 void IndexedDBQuotaClient::DidGetOriginsForHost( |
| 261 const std::string& host, const std::set<GURL>& origins, | 259 const std::string& host, const std::set<GURL>& origins, |
| 262 quota::StorageType type) { | 260 quota::StorageType type) { |
| 263 DCHECK(origins_for_host_callbacks_.HasCallbacks(host)); | 261 DCHECK(origins_for_host_callbacks_.HasCallbacks(host)); |
| 264 origins_for_host_callbacks_.Run(host, origins, type); | 262 origins_for_host_callbacks_.Run(host, origins, type); |
| 265 } | 263 } |
| OLD | NEW |