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

Side by Side Diff: chrome/browser/chromeos/file_manager/snapshot_manager.cc

Issue 564503002: Remove implicit conversions from scoped_refptr to T* in c/b/chromeos/file* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chromeos/file_manager/snapshot_manager.h" 5 #include "chrome/browser/chromeos/file_manager/snapshot_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/sys_info.h" 8 #include "base/sys_info.h"
9 #include "chrome/browser/chromeos/file_manager/app_id.h" 9 #include "chrome/browser/chromeos/file_manager/app_id.h"
10 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" 10 #include "chrome/browser/chromeos/file_manager/fileapi_util.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 base::Bind(&FreeReferenceOnIOThread, file_refs_)); 121 base::Bind(&FreeReferenceOnIOThread, file_refs_));
122 DCHECK(posted); 122 DCHECK(posted);
123 } 123 }
124 } 124 }
125 125
126 void SnapshotManager::CreateManagedSnapshot( 126 void SnapshotManager::CreateManagedSnapshot(
127 const base::FilePath& absolute_file_path, 127 const base::FilePath& absolute_file_path,
128 const LocalPathCallback& callback) { 128 const LocalPathCallback& callback) {
129 scoped_refptr<storage::FileSystemContext> context( 129 scoped_refptr<storage::FileSystemContext> context(
130 util::GetFileSystemContextForExtensionId(profile_, kFileManagerAppId)); 130 util::GetFileSystemContextForExtensionId(profile_, kFileManagerAppId));
131 DCHECK(context); 131 DCHECK(context.get());
132 132
133 GURL url; 133 GURL url;
134 if (!util::ConvertAbsoluteFilePathToFileSystemUrl( 134 if (!util::ConvertAbsoluteFilePathToFileSystemUrl(
135 profile_, absolute_file_path, kFileManagerAppId, &url)) { 135 profile_, absolute_file_path, kFileManagerAppId, &url)) {
136 callback.Run(base::FilePath()); 136 callback.Run(base::FilePath());
137 return; 137 return;
138 } 138 }
139 storage::FileSystemURL filesystem_url = context->CrackURL(url); 139 storage::FileSystemURL filesystem_url = context->CrackURL(url);
140 140
141 ComputeSpaceNeedToBeFreed(profile_, context, filesystem_url, 141 ComputeSpaceNeedToBeFreed(profile_, context, filesystem_url,
142 base::Bind(&SnapshotManager::CreateManagedSnapshotAfterSpaceComputed, 142 base::Bind(&SnapshotManager::CreateManagedSnapshotAfterSpaceComputed,
143 weak_ptr_factory_.GetWeakPtr(), 143 weak_ptr_factory_.GetWeakPtr(),
144 filesystem_url, 144 filesystem_url,
145 callback)); 145 callback));
146 } 146 }
147 147
148 void SnapshotManager::CreateManagedSnapshotAfterSpaceComputed( 148 void SnapshotManager::CreateManagedSnapshotAfterSpaceComputed(
149 const storage::FileSystemURL& filesystem_url, 149 const storage::FileSystemURL& filesystem_url,
150 const LocalPathCallback& callback, 150 const LocalPathCallback& callback,
151 int64 needed_space) { 151 int64 needed_space) {
152 scoped_refptr<storage::FileSystemContext> context( 152 scoped_refptr<storage::FileSystemContext> context(
153 util::GetFileSystemContextForExtensionId(profile_, kFileManagerAppId)); 153 util::GetFileSystemContextForExtensionId(profile_, kFileManagerAppId));
154 DCHECK(context); 154 DCHECK(context.get());
155 155
156 if (needed_space < 0) { 156 if (needed_space < 0) {
157 callback.Run(base::FilePath()); 157 callback.Run(base::FilePath());
158 return; 158 return;
159 } 159 }
160 160
161 // Free up to the required size. 161 // Free up to the required size.
162 std::deque<FileReferenceWithSizeInfo> to_free; 162 std::deque<FileReferenceWithSizeInfo> to_free;
163 while (needed_space > 0 && !file_refs_.empty()) { 163 while (needed_space > 0 && !file_refs_.empty()) {
164 needed_space -= file_refs_.front().file_size; 164 needed_space -= file_refs_.front().file_size;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 if (result != base::File::FILE_OK) { 203 if (result != base::File::FILE_OK) {
204 callback.Run(base::FilePath()); 204 callback.Run(base::FilePath());
205 return; 205 return;
206 } 206 }
207 207
208 file_refs_.push_back(FileReferenceWithSizeInfo(file_ref, file_info.size)); 208 file_refs_.push_back(FileReferenceWithSizeInfo(file_ref, file_info.size));
209 callback.Run(platform_path); 209 callback.Run(platform_path);
210 } 210 }
211 211
212 } // namespace file_manager 212 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698