Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(813)

Side by Side Diff: chrome/browser/browsing_data/browsing_data_file_system_helper.cc

Issue 1542413002: Switch to standard integer types in chrome/browser/, part 1 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
12 #include "base/sequenced_task_runner.h" 13 #include "base/sequenced_task_runner.h"
13 #include "chrome/browser/browsing_data/browsing_data_helper.h" 14 #include "chrome/browser/browsing_data/browsing_data_helper.h"
14 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
15 #include "storage/browser/fileapi/file_system_context.h" 16 #include "storage/browser/fileapi/file_system_context.h"
16 #include "storage/browser/fileapi/file_system_quota_util.h" 17 #include "storage/browser/fileapi/file_system_quota_util.h"
17 #include "storage/common/fileapi/file_system_types.h" 18 #include "storage/common/fileapi/file_system_types.h"
18 19
19 using content::BrowserThread; 20 using content::BrowserThread;
20 21
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 for (size_t i = 0; i < arraysize(types); ++i) { 110 for (size_t i = 0; i < arraysize(types); ++i) {
110 storage::FileSystemType type = types[i]; 111 storage::FileSystemType type = types[i];
111 storage::FileSystemQuotaUtil* quota_util = 112 storage::FileSystemQuotaUtil* quota_util =
112 filesystem_context_->GetQuotaUtil(type); 113 filesystem_context_->GetQuotaUtil(type);
113 DCHECK(quota_util); 114 DCHECK(quota_util);
114 std::set<GURL> origins; 115 std::set<GURL> origins;
115 quota_util->GetOriginsForTypeOnFileTaskRunner(type, &origins); 116 quota_util->GetOriginsForTypeOnFileTaskRunner(type, &origins);
116 for (const GURL& current : origins) { 117 for (const GURL& current : origins) {
117 if (!BrowsingDataHelper::HasWebScheme(current)) 118 if (!BrowsingDataHelper::HasWebScheme(current))
118 continue; // Non-websafe state is not considered browsing data. 119 continue; // Non-websafe state is not considered browsing data.
119 int64 usage = quota_util->GetOriginUsageOnFileTaskRunner( 120 int64_t usage = quota_util->GetOriginUsageOnFileTaskRunner(
120 filesystem_context_.get(), current, type); 121 filesystem_context_.get(), current, type);
121 OriginInfoMap::iterator inserted = 122 OriginInfoMap::iterator inserted =
122 file_system_info_map.insert( 123 file_system_info_map.insert(
123 std::make_pair(current, FileSystemInfo(current))).first; 124 std::make_pair(current, FileSystemInfo(current))).first;
124 inserted->second.usage_map[type] = usage; 125 inserted->second.usage_map[type] = usage;
125 } 126 }
126 } 127 }
127 128
128 for (const auto& iter : file_system_info_map) 129 for (const auto& iter : file_system_info_map)
129 result.push_back(iter.second); 130 result.push_back(iter.second);
(...skipping 23 matching lines...) Expand all
153 154
154 CannedBrowsingDataFileSystemHelper::CannedBrowsingDataFileSystemHelper( 155 CannedBrowsingDataFileSystemHelper::CannedBrowsingDataFileSystemHelper(
155 Profile* profile) { 156 Profile* profile) {
156 } 157 }
157 158
158 CannedBrowsingDataFileSystemHelper::~CannedBrowsingDataFileSystemHelper() {} 159 CannedBrowsingDataFileSystemHelper::~CannedBrowsingDataFileSystemHelper() {}
159 160
160 void CannedBrowsingDataFileSystemHelper::AddFileSystem( 161 void CannedBrowsingDataFileSystemHelper::AddFileSystem(
161 const GURL& origin, 162 const GURL& origin,
162 const storage::FileSystemType type, 163 const storage::FileSystemType type,
163 const int64 size) { 164 const int64_t size) {
164 DCHECK_CURRENTLY_ON(BrowserThread::UI); 165 DCHECK_CURRENTLY_ON(BrowserThread::UI);
165 // This canned implementation of AddFileSystem uses an O(n^2) algorithm; which 166 // This canned implementation of AddFileSystem uses an O(n^2) algorithm; which
166 // is fine, as it isn't meant for use in a high-volume context. If it turns 167 // is fine, as it isn't meant for use in a high-volume context. If it turns
167 // out that we want to start using this in a context with many, many origins, 168 // out that we want to start using this in a context with many, many origins,
168 // we should think about reworking the implementation. 169 // we should think about reworking the implementation.
169 bool duplicate_origin = false; 170 bool duplicate_origin = false;
170 for (FileSystemInfo& file_system : file_system_info_) { 171 for (FileSystemInfo& file_system : file_system_info_) {
171 if (file_system.origin == origin) { 172 if (file_system.origin == origin) {
172 file_system.usage_map[type] = size; 173 file_system.usage_map[type] = size;
173 duplicate_origin = true; 174 duplicate_origin = true;
(...skipping 25 matching lines...) Expand all
199 } 200 }
200 201
201 void CannedBrowsingDataFileSystemHelper::StartFetching( 202 void CannedBrowsingDataFileSystemHelper::StartFetching(
202 const FetchCallback& callback) { 203 const FetchCallback& callback) {
203 DCHECK_CURRENTLY_ON(BrowserThread::UI); 204 DCHECK_CURRENTLY_ON(BrowserThread::UI);
204 DCHECK(!callback.is_null()); 205 DCHECK(!callback.is_null());
205 206
206 BrowserThread::PostTask( 207 BrowserThread::PostTask(
207 BrowserThread::UI, FROM_HERE, base::Bind(callback, file_system_info_)); 208 BrowserThread::UI, FROM_HERE, base::Bind(callback, file_system_info_));
208 } 209 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698