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 "content/browser/indexed_db/indexed_db_context_impl.h" | 5 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 data_path_ = data_path.Append(kIndexedDBDirectory); | 96 data_path_ = data_path.Append(kIndexedDBDirectory); |
97 if (quota_manager_proxy && | 97 if (quota_manager_proxy && |
98 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) { | 98 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) { |
99 quota_manager_proxy->RegisterClient( | 99 quota_manager_proxy->RegisterClient( |
100 new IndexedDBQuotaClient(webkit_thread_loop, this)); | 100 new IndexedDBQuotaClient(webkit_thread_loop, this)); |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
104 WebIDBFactory* IndexedDBContextImpl::GetIDBFactory() { | 104 WebIDBFactory* IndexedDBContextImpl::GetIDBFactory() { |
105 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 105 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
106 if (!idb_factory_.get()) { | 106 if (!idb_factory_) { |
107 // Prime our cache of origins with existing databases so we can | 107 // Prime our cache of origins with existing databases so we can |
108 // detect when dbs are newly created. | 108 // detect when dbs are newly created. |
109 GetOriginSet(); | 109 GetOriginSet(); |
110 idb_factory_.reset(WebIDBFactory::create()); | 110 idb_factory_.reset(WebIDBFactory::create()); |
111 } | 111 } |
112 return idb_factory_.get(); | 112 return idb_factory_.get(); |
113 } | 113 } |
114 | 114 |
115 std::vector<GURL> IndexedDBContextImpl::GetAllOrigins() { | 115 std::vector<GURL> IndexedDBContextImpl::GetAllOrigins() { |
116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); | 116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 360 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
361 if (!quota_manager_proxy() || !quota_manager_proxy()->quota_manager()) | 361 if (!quota_manager_proxy() || !quota_manager_proxy()->quota_manager()) |
362 return; | 362 return; |
363 quota_manager_proxy()->quota_manager()->GetUsageAndQuota( | 363 quota_manager_proxy()->quota_manager()->GetUsageAndQuota( |
364 origin_url, | 364 origin_url, |
365 quota::kStorageTypeTemporary, | 365 quota::kStorageTypeTemporary, |
366 base::Bind(&IndexedDBContextImpl::GotUsageAndQuota, this, origin_url)); | 366 base::Bind(&IndexedDBContextImpl::GotUsageAndQuota, this, origin_url)); |
367 } | 367 } |
368 | 368 |
369 std::set<GURL>* IndexedDBContextImpl::GetOriginSet() { | 369 std::set<GURL>* IndexedDBContextImpl::GetOriginSet() { |
370 if (!origin_set_.get()) { | 370 if (!origin_set_) { |
371 origin_set_.reset(new std::set<GURL>); | 371 origin_set_.reset(new std::set<GURL>); |
372 std::vector<GURL> origins; | 372 std::vector<GURL> origins; |
373 GetAllOriginsAndPaths(data_path_, &origins, NULL); | 373 GetAllOriginsAndPaths(data_path_, &origins, NULL); |
374 for (std::vector<GURL>::const_iterator iter = origins.begin(); | 374 for (std::vector<GURL>::const_iterator iter = origins.begin(); |
375 iter != origins.end(); ++iter) { | 375 iter != origins.end(); ++iter) { |
376 origin_set_->insert(*iter); | 376 origin_set_->insert(*iter); |
377 } | 377 } |
378 } | 378 } |
379 return origin_set_.get(); | 379 return origin_set_.get(); |
380 } | 380 } |
381 | 381 |
382 void IndexedDBContextImpl::ResetCaches() { | 382 void IndexedDBContextImpl::ResetCaches() { |
383 origin_set_.reset(); | 383 origin_set_.reset(); |
384 origin_size_map_.clear(); | 384 origin_size_map_.clear(); |
385 space_available_map_.clear(); | 385 space_available_map_.clear(); |
386 } | 386 } |
387 | 387 |
388 } // namespace content | 388 } // namespace content |
OLD | NEW |