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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 if (!data_path.empty()) | 101 if (!data_path.empty()) |
102 data_path_ = data_path.Append(kIndexedDBDirectory); | 102 data_path_ = data_path.Append(kIndexedDBDirectory); |
103 if (quota_manager_proxy && | 103 if (quota_manager_proxy && |
104 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) { | 104 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) { |
105 quota_manager_proxy->RegisterClient(new IndexedDBQuotaClient(this)); | 105 quota_manager_proxy->RegisterClient(new IndexedDBQuotaClient(this)); |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 IndexedDBFactory* IndexedDBContextImpl::GetIDBFactory() { | 109 IndexedDBFactory* IndexedDBContextImpl::GetIDBFactory() { |
110 DCHECK(TaskRunner()->RunsTasksOnCurrentThread()); | 110 DCHECK(TaskRunner()->RunsTasksOnCurrentThread()); |
111 if (!idb_factory_) { | 111 if (!idb_factory_.get()) { |
112 // Prime our cache of origins with existing databases so we can | 112 // Prime our cache of origins with existing databases so we can |
113 // detect when dbs are newly created. | 113 // detect when dbs are newly created. |
114 GetOriginSet(); | 114 GetOriginSet(); |
115 idb_factory_ = IndexedDBFactory::Create(); | 115 idb_factory_ = IndexedDBFactory::Create(); |
116 } | 116 } |
117 return idb_factory_; | 117 return idb_factory_.get(); |
118 } | 118 } |
119 | 119 |
120 std::vector<GURL> IndexedDBContextImpl::GetAllOrigins() { | 120 std::vector<GURL> IndexedDBContextImpl::GetAllOrigins() { |
121 DCHECK(TaskRunner()->RunsTasksOnCurrentThread()); | 121 DCHECK(TaskRunner()->RunsTasksOnCurrentThread()); |
122 std::vector<GURL> origins; | 122 std::vector<GURL> origins; |
123 std::set<GURL>* origins_set = GetOriginSet(); | 123 std::set<GURL>* origins_set = GetOriginSet(); |
124 for (std::set<GURL>::const_iterator iter = origins_set->begin(); | 124 for (std::set<GURL>::const_iterator iter = origins_set->begin(); |
125 iter != origins_set->end(); | 125 iter != origins_set->end(); |
126 ++iter) { | 126 ++iter) { |
127 origins.push_back(*iter); | 127 origins.push_back(*iter); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 bool IndexedDBContextImpl::IsOverQuota(const GURL& origin_url) { | 281 bool IndexedDBContextImpl::IsOverQuota(const GURL& origin_url) { |
282 const int kOneAdditionalByte = 1; | 282 const int kOneAdditionalByte = 1; |
283 return WouldBeOverQuota(origin_url, kOneAdditionalByte); | 283 return WouldBeOverQuota(origin_url, kOneAdditionalByte); |
284 } | 284 } |
285 | 285 |
286 quota::QuotaManagerProxy* IndexedDBContextImpl::quota_manager_proxy() { | 286 quota::QuotaManagerProxy* IndexedDBContextImpl::quota_manager_proxy() { |
287 return quota_manager_proxy_.get(); | 287 return quota_manager_proxy_.get(); |
288 } | 288 } |
289 | 289 |
290 IndexedDBContextImpl::~IndexedDBContextImpl() { | 290 IndexedDBContextImpl::~IndexedDBContextImpl() { |
291 if (idb_factory_) { | 291 if (idb_factory_.get()) { |
292 IndexedDBFactory* factory = idb_factory_.get(); | 292 IndexedDBFactory* factory = idb_factory_.get(); |
293 factory->AddRef(); | 293 factory->AddRef(); |
294 idb_factory_ = NULL; | 294 idb_factory_ = NULL; |
295 if (!task_runner_->ReleaseSoon(FROM_HERE, factory)) { | 295 if (!task_runner_->ReleaseSoon(FROM_HERE, factory)) { |
296 factory->Release(); | 296 factory->Release(); |
297 } | 297 } |
298 } | 298 } |
299 | 299 |
300 if (data_path_.empty()) | 300 if (data_path_.empty()) |
301 return; | 301 return; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 origin_set_.reset(); | 424 origin_set_.reset(); |
425 origin_size_map_.clear(); | 425 origin_size_map_.clear(); |
426 space_available_map_.clear(); | 426 space_available_map_.clear(); |
427 } | 427 } |
428 | 428 |
429 base::TaskRunner* IndexedDBContextImpl::TaskRunner() const { | 429 base::TaskRunner* IndexedDBContextImpl::TaskRunner() const { |
430 return task_runner_; | 430 return task_runner_; |
431 } | 431 } |
432 | 432 |
433 } // namespace content | 433 } // namespace content |
OLD | NEW |