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

Side by Side Diff: chrome/browser/chromeos/fileapi/external_file_url_request_job.cc

Issue 1547093002: Switch to standard integer types in chrome/browser/chromeos/. (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 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/fileapi/external_file_url_request_job.h" 5 #include "chrome/browser/chromeos/fileapi/external_file_url_request_job.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/thread_task_runner_handle.h" 14 #include "base/thread_task_runner_handle.h"
14 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" 16 #include "chrome/browser/chromeos/file_manager/fileapi_util.h"
16 #include "chrome/browser/chromeos/fileapi/external_file_url_util.h" 17 #include "chrome/browser/chromeos/fileapi/external_file_url_util.h"
17 #include "chrome/browser/extensions/api/file_handlers/mime_util.h" 18 #include "chrome/browser/extensions/api/file_handlers/mime_util.h"
18 #include "chrome/browser/profiles/profile_manager.h" 19 #include "chrome/browser/profiles/profile_manager.h"
19 #include "components/drive/file_system_core_util.h" 20 #include "components/drive/file_system_core_util.h"
20 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/storage_partition.h" 22 #include "content/public/browser/storage_partition.h"
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 net::URLRequestStatus(net::URLRequestStatus::FAILED, net::ERR_FAILED)); 291 net::URLRequestStatus(net::URLRequestStatus::FAILED, net::ERR_FAILED));
291 return; 292 return;
292 } 293 }
293 294
294 // Compute content size. 295 // Compute content size.
295 if (!byte_range_.ComputeBounds(file_info.size)) { 296 if (!byte_range_.ComputeBounds(file_info.size)) {
296 NotifyStartError(net::URLRequestStatus( 297 NotifyStartError(net::URLRequestStatus(
297 net::URLRequestStatus::FAILED, net::ERR_REQUEST_RANGE_NOT_SATISFIABLE)); 298 net::URLRequestStatus::FAILED, net::ERR_REQUEST_RANGE_NOT_SATISFIABLE));
298 return; 299 return;
299 } 300 }
300 const int64 offset = byte_range_.first_byte_position(); 301 const int64_t offset = byte_range_.first_byte_position();
301 const int64 size = 302 const int64_t size =
302 byte_range_.last_byte_position() + 1 - byte_range_.first_byte_position(); 303 byte_range_.last_byte_position() + 1 - byte_range_.first_byte_position();
303 set_expected_content_size(size); 304 set_expected_content_size(size);
304 remaining_bytes_ = size; 305 remaining_bytes_ = size;
305 306
306 // Create file stream reader. 307 // Create file stream reader.
307 stream_reader_ = file_system_context_->CreateFileStreamReader( 308 stream_reader_ = file_system_context_->CreateFileStreamReader(
308 file_system_url_, offset, size, base::Time()); 309 file_system_url_, offset, size, base::Time());
309 if (!stream_reader_) { 310 if (!stream_reader_) {
310 NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED, 311 NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED,
311 net::ERR_FILE_NOT_FOUND)); 312 net::ERR_FILE_NOT_FOUND));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 } 346 }
346 347
347 int ExternalFileURLRequestJob::ReadRawData(net::IOBuffer* buf, int buf_size) { 348 int ExternalFileURLRequestJob::ReadRawData(net::IOBuffer* buf, int buf_size) {
348 DCHECK_CURRENTLY_ON(BrowserThread::IO); 349 DCHECK_CURRENTLY_ON(BrowserThread::IO);
349 DCHECK(stream_reader_); 350 DCHECK(stream_reader_);
350 351
351 if (remaining_bytes_ == 0) 352 if (remaining_bytes_ == 0)
352 return 0; 353 return 0;
353 354
354 const int result = stream_reader_->Read( 355 const int result = stream_reader_->Read(
355 buf, std::min<int64>(buf_size, remaining_bytes_), 356 buf, std::min<int64_t>(buf_size, remaining_bytes_),
356 base::Bind(&ExternalFileURLRequestJob::OnReadCompleted, 357 base::Bind(&ExternalFileURLRequestJob::OnReadCompleted,
357 weak_ptr_factory_.GetWeakPtr())); 358 weak_ptr_factory_.GetWeakPtr()));
358 359
359 if (result < 0) 360 if (result < 0)
360 return result; 361 return result;
361 362
362 remaining_bytes_ -= result; 363 remaining_bytes_ -= result;
363 return result; 364 return result;
364 } 365 }
365 366
366 ExternalFileURLRequestJob::~ExternalFileURLRequestJob() { 367 ExternalFileURLRequestJob::~ExternalFileURLRequestJob() {
367 } 368 }
368 369
369 void ExternalFileURLRequestJob::OnReadCompleted(int read_result) { 370 void ExternalFileURLRequestJob::OnReadCompleted(int read_result) {
370 DCHECK_CURRENTLY_ON(BrowserThread::IO); 371 DCHECK_CURRENTLY_ON(BrowserThread::IO);
371 372
372 if (read_result > 0) 373 if (read_result > 0)
373 remaining_bytes_ -= read_result; 374 remaining_bytes_ -= read_result;
374 375
375 ReadRawDataComplete(read_result); 376 ReadRawDataComplete(read_result);
376 } 377 }
377 378
378 } // namespace chromeos 379 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698