| 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 "chrome/browser/browsing_data/browsing_data_file_system_helper.h" | 5 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 }; | 129 }; |
| 130 | 130 |
| 131 typedef std::map<GURL, FileSystemInfo> OriginInfoMap; | 131 typedef std::map<GURL, FileSystemInfo> OriginInfoMap; |
| 132 OriginInfoMap file_system_info_map; | 132 OriginInfoMap file_system_info_map; |
| 133 for (size_t i = 0; i < arraysize(types); ++i) { | 133 for (size_t i = 0; i < arraysize(types); ++i) { |
| 134 fileapi::FileSystemType type = types[i]; | 134 fileapi::FileSystemType type = types[i]; |
| 135 fileapi::FileSystemQuotaUtil* quota_util = | 135 fileapi::FileSystemQuotaUtil* quota_util = |
| 136 filesystem_context_->GetQuotaUtil(type); | 136 filesystem_context_->GetQuotaUtil(type); |
| 137 DCHECK(quota_util); | 137 DCHECK(quota_util); |
| 138 std::set<GURL> origins; | 138 std::set<GURL> origins; |
| 139 quota_util->GetOriginsForTypeOnFileThread(type, &origins); | 139 quota_util->GetOriginsForTypeOnFileTaskRunner(type, &origins); |
| 140 for (std::set<GURL>::iterator iter = origins.begin(); | 140 for (std::set<GURL>::iterator iter = origins.begin(); |
| 141 iter != origins.end(); ++iter) { | 141 iter != origins.end(); ++iter) { |
| 142 const GURL& current = *iter; | 142 const GURL& current = *iter; |
| 143 if (!BrowsingDataHelper::HasWebScheme(current)) | 143 if (!BrowsingDataHelper::HasWebScheme(current)) |
| 144 continue; // Non-websafe state is not considered browsing data. | 144 continue; // Non-websafe state is not considered browsing data. |
| 145 int64 usage = quota_util->GetOriginUsageOnFileThread( | 145 int64 usage = quota_util->GetOriginUsageOnFileTaskRunner( |
| 146 filesystem_context_.get(), current, type); | 146 filesystem_context_.get(), current, type); |
| 147 OriginInfoMap::iterator inserted = | 147 OriginInfoMap::iterator inserted = |
| 148 file_system_info_map.insert( | 148 file_system_info_map.insert( |
| 149 std::make_pair(current, FileSystemInfo(current))).first; | 149 std::make_pair(current, FileSystemInfo(current))).first; |
| 150 inserted->second.usage_map[type] = usage; | 150 inserted->second.usage_map[type] = usage; |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 | 153 |
| 154 for (OriginInfoMap::iterator iter = file_system_info_map.begin(); | 154 for (OriginInfoMap::iterator iter = file_system_info_map.begin(); |
| 155 iter != file_system_info_map.end(); ++iter) { | 155 iter != file_system_info_map.end(); ++iter) { |
| 156 file_system_info_.push_back(iter->second); | 156 file_system_info_.push_back(iter->second); |
| 157 } | 157 } |
| 158 | 158 |
| 159 BrowserThread::PostTask( | 159 BrowserThread::PostTask( |
| 160 BrowserThread::UI, FROM_HERE, | 160 BrowserThread::UI, FROM_HERE, |
| 161 base::Bind(&BrowsingDataFileSystemHelperImpl::NotifyOnUIThread, this)); | 161 base::Bind(&BrowsingDataFileSystemHelperImpl::NotifyOnUIThread, this)); |
| 162 } | 162 } |
| 163 | 163 |
| 164 void BrowsingDataFileSystemHelperImpl::NotifyOnUIThread() { | 164 void BrowsingDataFileSystemHelperImpl::NotifyOnUIThread() { |
| 165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 166 DCHECK(is_fetching_); | 166 DCHECK(is_fetching_); |
| 167 completion_callback_.Run(file_system_info_); | 167 completion_callback_.Run(file_system_info_); |
| 168 completion_callback_.Reset(); | 168 completion_callback_.Reset(); |
| 169 is_fetching_ = false; | 169 is_fetching_ = false; |
| 170 } | 170 } |
| 171 | 171 |
| 172 void BrowsingDataFileSystemHelperImpl::DeleteFileSystemOriginInFileThread( | 172 void BrowsingDataFileSystemHelperImpl::DeleteFileSystemOriginInFileThread( |
| 173 const GURL& origin) { | 173 const GURL& origin) { |
| 174 DCHECK(file_task_runner()->RunsTasksOnCurrentThread()); | 174 DCHECK(file_task_runner()->RunsTasksOnCurrentThread()); |
| 175 filesystem_context_->DeleteDataForOriginOnFileThread(origin); | 175 filesystem_context_->DeleteDataForOriginOnFileTaskRunner(origin); |
| 176 } | 176 } |
| 177 | 177 |
| 178 } // namespace | 178 } // namespace |
| 179 | 179 |
| 180 BrowsingDataFileSystemHelper::FileSystemInfo::FileSystemInfo( | 180 BrowsingDataFileSystemHelper::FileSystemInfo::FileSystemInfo( |
| 181 const GURL& origin) : origin(origin) {} | 181 const GURL& origin) : origin(origin) {} |
| 182 | 182 |
| 183 BrowsingDataFileSystemHelper::FileSystemInfo::~FileSystemInfo() {} | 183 BrowsingDataFileSystemHelper::FileSystemInfo::~FileSystemInfo() {} |
| 184 | 184 |
| 185 // static | 185 // static |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 base::Bind(&CannedBrowsingDataFileSystemHelper::NotifyOnUIThread, this)); | 265 base::Bind(&CannedBrowsingDataFileSystemHelper::NotifyOnUIThread, this)); |
| 266 } | 266 } |
| 267 | 267 |
| 268 void CannedBrowsingDataFileSystemHelper::NotifyOnUIThread() { | 268 void CannedBrowsingDataFileSystemHelper::NotifyOnUIThread() { |
| 269 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 269 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 270 DCHECK(is_fetching_); | 270 DCHECK(is_fetching_); |
| 271 completion_callback_.Run(file_system_info_); | 271 completion_callback_.Run(file_system_info_); |
| 272 completion_callback_.Reset(); | 272 completion_callback_.Reset(); |
| 273 is_fetching_ = false; | 273 is_fetching_ = false; |
| 274 } | 274 } |
| OLD | NEW |