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

Side by Side Diff: chrome/browser/ui/webui/screenshot_source.cc

Issue 14884015: drive: Remove DriveFileType (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/screenshot_source.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ui/webui/screenshot_source.h" 5 #include "chrome/browser/ui/webui/screenshot_source.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 read_bytes->clear(); 239 read_bytes->clear();
240 240
241 CacheAndSendScreenshot(screenshot_path, callback, read_bytes); 241 CacheAndSendScreenshot(screenshot_path, callback, read_bytes);
242 } 242 }
243 243
244 void ScreenshotSource::GetSavedScreenshotCallback( 244 void ScreenshotSource::GetSavedScreenshotCallback(
245 const std::string& screenshot_path, 245 const std::string& screenshot_path,
246 const content::URLDataSource::GotDataCallback& callback, 246 const content::URLDataSource::GotDataCallback& callback,
247 drive::FileError error, 247 drive::FileError error,
248 const base::FilePath& file, 248 const base::FilePath& file,
249 const std::string& unused_mime_type, 249 scoped_ptr<drive::ResourceEntry> entry) {
250 drive::DriveFileType file_type) { 250 if (error != drive::FILE_ERROR_OK) {
251 if (error != drive::FILE_ERROR_OK || file_type != drive::REGULAR_FILE) {
252 ScreenshotDataPtr read_bytes(new ScreenshotData); 251 ScreenshotDataPtr read_bytes(new ScreenshotData);
253 CacheAndSendScreenshot(screenshot_path, callback, read_bytes); 252 CacheAndSendScreenshot(screenshot_path, callback, read_bytes);
254 return; 253 return;
255 } 254 }
256 255
257 content::BrowserThread::PostTask( 256 content::BrowserThread::PostTask(
258 content::BrowserThread::FILE, FROM_HERE, 257 content::BrowserThread::FILE, FROM_HERE,
259 base::Bind(&ScreenshotSource::SendSavedScreenshot, 258 base::Bind(&ScreenshotSource::SendSavedScreenshot,
260 base::Unretained(this), screenshot_path, callback, file)); 259 base::Unretained(this), screenshot_path, callback, file));
261 } 260 }
262 #endif 261 #endif
263 262
264 void ScreenshotSource::CacheAndSendScreenshot( 263 void ScreenshotSource::CacheAndSendScreenshot(
265 const std::string& screenshot_path, 264 const std::string& screenshot_path,
266 const content::URLDataSource::GotDataCallback& callback, 265 const content::URLDataSource::GotDataCallback& callback,
267 ScreenshotDataPtr bytes) { 266 ScreenshotDataPtr bytes) {
268 // Strip the query from the screenshot path. 267 // Strip the query from the screenshot path.
269 std::string path = screenshot_path.substr( 268 std::string path = screenshot_path.substr(
270 0, screenshot_path.find_first_of("?")); 269 0, screenshot_path.find_first_of("?"));
271 cached_screenshots_[path] = bytes; 270 cached_screenshots_[path] = bytes;
272 callback.Run(new base::RefCountedBytes(*bytes)); 271 callback.Run(new base::RefCountedBytes(*bytes));
273 } 272 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/screenshot_source.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698