| Index: content/browser/in_process_webkit/indexed_db_quota_client.cc
|
| diff --git a/content/browser/in_process_webkit/indexed_db_quota_client.cc b/content/browser/in_process_webkit/indexed_db_quota_client.cc
|
| index 53d9e9bd59aa10b0a28c504a1a0e52540f06877f..fbebee791e97f8e669c65410c8f514078bfc8cad 100644
|
| --- a/content/browser/in_process_webkit/indexed_db_quota_client.cc
|
| +++ b/content/browser/in_process_webkit/indexed_db_quota_client.cc
|
| @@ -42,7 +42,7 @@ void GetAllOriginsOnWebKitThread(
|
| origins_to_return->insert(all_origins.begin(), all_origins.end());
|
| }
|
|
|
| -void DidGetAllOrigins(
|
| +void DidGetOrigins(
|
| const IndexedDBQuotaClient::GetOriginsCallback& callback,
|
| const std::set<GURL>* origins,
|
| quota::StorageType storage_type) {
|
| @@ -50,77 +50,20 @@ void DidGetAllOrigins(
|
| callback.Run(*origins, storage_type);
|
| }
|
|
|
| -} // namespace
|
| -
|
| -// Helper tasks ---------------------------------------------------------------
|
| -
|
| -class IndexedDBQuotaClient::HelperTask : public quota::QuotaThreadTask {
|
| - protected:
|
| - HelperTask(
|
| - IndexedDBQuotaClient* client,
|
| - base::MessageLoopProxy* webkit_thread_message_loop)
|
| - : QuotaThreadTask(client, webkit_thread_message_loop),
|
| - client_(client), indexed_db_context_(client->indexed_db_context_) {
|
| - }
|
| -
|
| - IndexedDBQuotaClient* client_;
|
| - scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
|
| -
|
| - protected:
|
| - virtual ~HelperTask() {}
|
| -};
|
| -
|
| -class IndexedDBQuotaClient::GetOriginsTaskBase : public HelperTask {
|
| - protected:
|
| - GetOriginsTaskBase(
|
| - IndexedDBQuotaClient* client,
|
| - base::MessageLoopProxy* webkit_thread_message_loop)
|
| - : HelperTask(client, webkit_thread_message_loop) {
|
| - }
|
| -
|
| - virtual bool ShouldAddOrigin(const GURL& origin) = 0;
|
| -
|
| - virtual void RunOnTargetThread() OVERRIDE {
|
| - std::vector<GURL> origins = indexed_db_context_->GetAllOrigins();
|
| - for (std::vector<GURL>::const_iterator iter = origins.begin();
|
| - iter != origins.end(); ++iter) {
|
| - if (ShouldAddOrigin(*iter))
|
| - origins_.insert(*iter);
|
| - }
|
| - }
|
| -
|
| - std::set<GURL> origins_;
|
| -
|
| - protected:
|
| - virtual ~GetOriginsTaskBase() {}
|
| -};
|
| -
|
| -class IndexedDBQuotaClient::GetOriginsForHostTask : public GetOriginsTaskBase {
|
| - public:
|
| - GetOriginsForHostTask(
|
| - IndexedDBQuotaClient* client,
|
| - base::MessageLoopProxy* webkit_thread_message_loop,
|
| - const std::string& host,
|
| - quota::StorageType type)
|
| - : GetOriginsTaskBase(client, webkit_thread_message_loop),
|
| - host_(host),
|
| - type_(type) {
|
| - }
|
| -
|
| - private:
|
| - virtual ~GetOriginsForHostTask() {}
|
| -
|
| - virtual bool ShouldAddOrigin(const GURL& origin) OVERRIDE {
|
| - return host_ == net::GetHostOrSpecFromURL(origin);
|
| - }
|
| -
|
| - virtual void Completed() OVERRIDE {
|
| - client_->DidGetOriginsForHost(host_, origins_, type_);
|
| +void GetOriginsForHostOnWebKitThread(
|
| + IndexedDBContextImpl* context,
|
| + const std::string& host,
|
| + std::set<GURL>* origins_to_return) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
|
| + std::vector<GURL> all_origins = context->GetAllOrigins();
|
| + for (std::vector<GURL>::const_iterator iter = all_origins.begin();
|
| + iter != all_origins.end(); ++iter) {
|
| + if (host == net::GetHostOrSpecFromURL(*iter))
|
| + origins_to_return->insert(*iter);
|
| }
|
| +}
|
|
|
| - std::string host_;
|
| - quota::StorageType type_;
|
| -};
|
| +} // namespace
|
|
|
| // IndexedDBQuotaClient --------------------------------------------------------
|
|
|
| @@ -182,7 +125,7 @@ void IndexedDBQuotaClient::GetOriginsForType(
|
| base::Bind(&GetAllOriginsOnWebKitThread,
|
| indexed_db_context_,
|
| base::Unretained(origins_to_return)),
|
| - base::Bind(&DidGetAllOrigins,
|
| + base::Bind(&DidGetOrigins,
|
| callback,
|
| base::Owned(origins_to_return),
|
| type));
|
| @@ -201,12 +144,17 @@ void IndexedDBQuotaClient::GetOriginsForHost(
|
| return;
|
| }
|
|
|
| - if (origins_for_host_callbacks_.Add(host, callback)) {
|
| - scoped_refptr<GetOriginsForHostTask> task(
|
| - new GetOriginsForHostTask(
|
| - this, webkit_thread_message_loop_, host, type));
|
| - task->Start();
|
| - }
|
| + std::set<GURL>* origins_to_return = new std::set<GURL>();
|
| + webkit_thread_message_loop_->PostTaskAndReply(
|
| + FROM_HERE,
|
| + base::Bind(&GetOriginsForHostOnWebKitThread,
|
| + indexed_db_context_,
|
| + host,
|
| + base::Unretained(origins_to_return)),
|
| + base::Bind(&DidGetOrigins,
|
| + callback,
|
| + base::Owned(origins_to_return),
|
| + type));
|
| }
|
|
|
| void IndexedDBQuotaClient::DeleteOriginData(
|
| @@ -226,10 +174,3 @@ void IndexedDBQuotaClient::DeleteOriginData(
|
| origin),
|
| callback);
|
| }
|
| -
|
| -void IndexedDBQuotaClient::DidGetOriginsForHost(
|
| - const std::string& host, const std::set<GURL>& origins,
|
| - quota::StorageType type) {
|
| - DCHECK(origins_for_host_callbacks_.HasCallbacks(host));
|
| - origins_for_host_callbacks_.Run(host, origins, type);
|
| -}
|
|
|