Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / media_galleries / win / snapshot_file_details.cc
blob1a862687f3d947d66aa2b621ef0033f7e48b0076
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/media_galleries/win/snapshot_file_details.h"
7 #include "base/basictypes.h"
9 ///////////////////////////////////////////////////////////////////////////////
10 // SnapshotRequestInfo //
11 ///////////////////////////////////////////////////////////////////////////////
13 SnapshotRequestInfo::SnapshotRequestInfo(
14 const base::FilePath& device_file_path,
15 const base::FilePath& snapshot_file_path,
16 const MTPDeviceAsyncDelegate::CreateSnapshotFileSuccessCallback&
17 success_callback,
18 const MTPDeviceAsyncDelegate::ErrorCallback& error_callback)
19 : device_file_path(device_file_path),
20 snapshot_file_path(snapshot_file_path),
21 success_callback(success_callback),
22 error_callback(error_callback) {
25 SnapshotRequestInfo::~SnapshotRequestInfo() {
28 ///////////////////////////////////////////////////////////////////////////////
29 // SnapshotFileDetails //
30 ///////////////////////////////////////////////////////////////////////////////
32 SnapshotFileDetails::SnapshotFileDetails(
33 const SnapshotRequestInfo& request_info)
34 : request_info_(request_info),
35 optimal_transfer_size_(0),
36 bytes_written_(0) {
39 SnapshotFileDetails::~SnapshotFileDetails() {
40 file_stream_.Release();
43 void SnapshotFileDetails::set_file_info(const base::File::Info& file_info) {
44 file_info_ = file_info;
47 void SnapshotFileDetails::set_device_file_stream(
48 IStream* file_stream) {
49 file_stream_ = file_stream;
52 void SnapshotFileDetails::set_optimal_transfer_size(
53 DWORD optimal_transfer_size) {
54 optimal_transfer_size_ = optimal_transfer_size;
57 bool SnapshotFileDetails::IsSnapshotFileWriteComplete() const {
58 return bytes_written_ == file_info_.size;
61 bool SnapshotFileDetails::AddBytesWritten(DWORD bytes_written) {
62 if ((bytes_written == 0) ||
63 (bytes_written_ > kuint64max - bytes_written) ||
64 (bytes_written_ + bytes_written > file_info_.size))
65 return false;
67 bytes_written_ += bytes_written;
68 return true;