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

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/job_event_router.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/extensions/file_manager/job_event_router.h" 5 #include "chrome/browser/chromeos/extensions/file_manager/job_event_router.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "chrome/browser/chromeos/file_manager/app_id.h" 10 #include "chrome/browser/chromeos/file_manager/app_id.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 // Forget about the job. 75 // Forget about the job.
76 drive_jobs_.erase(job_info.job_id); 76 drive_jobs_.erase(job_info.job_id);
77 if (!drive_jobs_.size()) { 77 if (!drive_jobs_.size()) {
78 num_completed_bytes_ = 0L; 78 num_completed_bytes_ = 0L;
79 num_total_bytes_ = 0L; 79 num_total_bytes_ = 0L;
80 } 80 }
81 } 81 }
82 82
83 void JobEventRouter::UpdateBytes(const drive::JobInfo& job_info) { 83 void JobEventRouter::UpdateBytes(const drive::JobInfo& job_info) {
84 int64 last_completed_bytes = 0; 84 int64_t last_completed_bytes = 0;
85 int64 last_total_bytes = 0; 85 int64_t last_total_bytes = 0;
86 if (drive_jobs_.count(job_info.job_id)) { 86 if (drive_jobs_.count(job_info.job_id)) {
87 last_completed_bytes = drive_jobs_[job_info.job_id]->num_completed_bytes; 87 last_completed_bytes = drive_jobs_[job_info.job_id]->num_completed_bytes;
88 last_total_bytes = drive_jobs_[job_info.job_id]->num_total_bytes; 88 last_total_bytes = drive_jobs_[job_info.job_id]->num_total_bytes;
89 } 89 }
90 num_completed_bytes_ += job_info.num_completed_bytes - last_completed_bytes; 90 num_completed_bytes_ += job_info.num_completed_bytes - last_completed_bytes;
91 num_total_bytes_ += job_info.num_total_bytes - last_total_bytes; 91 num_total_bytes_ += job_info.num_total_bytes - last_total_bytes;
92 } 92 }
93 93
94 void JobEventRouter::ScheduleDriveFileTransferEvent( 94 void JobEventRouter::ScheduleDriveFileTransferEvent(
95 const drive::JobInfo& job_info, 95 const drive::JobInfo& job_info,
(...skipping 27 matching lines...) Expand all
123 num_completed_bytes_, num_total_bytes_); 123 num_completed_bytes_, num_total_bytes_);
124 } 124 }
125 125
126 pending_job_info_.reset(); 126 pending_job_info_.reset();
127 } 127 }
128 128
129 void JobEventRouter::DispatchFileTransfersUpdateEventToExtension( 129 void JobEventRouter::DispatchFileTransfersUpdateEventToExtension(
130 const std::string& extension_id, 130 const std::string& extension_id,
131 const drive::JobInfo& job_info, 131 const drive::JobInfo& job_info,
132 const file_manager_private::TransferState& state, 132 const file_manager_private::TransferState& state,
133 const int64 num_total_jobs, 133 const int64_t num_total_jobs,
134 const int64 num_completed_bytes, 134 const int64_t num_completed_bytes,
135 const int64 num_total_bytes) { 135 const int64_t num_total_bytes) {
136 file_manager_private::FileTransferStatus status; 136 file_manager_private::FileTransferStatus status;
137 137
138 const GURL url = 138 const GURL url =
139 ConvertDrivePathToFileSystemUrl(job_info.file_path, extension_id); 139 ConvertDrivePathToFileSystemUrl(job_info.file_path, extension_id);
140 status.file_url = url.spec(); 140 status.file_url = url.spec();
141 status.transfer_state = state; 141 status.transfer_state = state;
142 status.transfer_type = IsUploadJob(job_info.job_type) 142 status.transfer_type = IsUploadJob(job_info.job_type)
143 ? file_manager_private::TRANSFER_TYPE_UPLOAD 143 ? file_manager_private::TRANSFER_TYPE_UPLOAD
144 : file_manager_private::TRANSFER_TYPE_DOWNLOAD; 144 : file_manager_private::TRANSFER_TYPE_DOWNLOAD;
145 // JavaScript does not have 64-bit integers. Instead we use double, which 145 // JavaScript does not have 64-bit integers. Instead we use double, which
146 // is in IEEE 754 formant and accurate up to 52-bits in JS, and in practice 146 // is in IEEE 754 formant and accurate up to 52-bits in JS, and in practice
147 // in C++. Larger values are rounded. 147 // in C++. Larger values are rounded.
148 status.num_total_jobs = num_total_jobs; 148 status.num_total_jobs = num_total_jobs;
149 status.processed = num_completed_bytes; 149 status.processed = num_completed_bytes;
150 status.total = num_total_bytes; 150 status.total = num_total_bytes;
151 151
152 DispatchEventToExtension( 152 DispatchEventToExtension(
153 extension_id, 153 extension_id,
154 extensions::events::FILE_MANAGER_PRIVATE_ON_FILE_TRANSFERS_UPDATED, 154 extensions::events::FILE_MANAGER_PRIVATE_ON_FILE_TRANSFERS_UPDATED,
155 file_manager_private::OnFileTransfersUpdated::kEventName, 155 file_manager_private::OnFileTransfersUpdated::kEventName,
156 file_manager_private::OnFileTransfersUpdated::Create(status)); 156 file_manager_private::OnFileTransfersUpdated::Create(status));
157 } 157 }
158 158
159 } // namespace file_manager 159 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698