| OLD | NEW |
| 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/drive/file_system_util.h" | 10 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 void JobEventRouter::SendDriveFileTransferEvent() { | 120 void JobEventRouter::SendDriveFileTransferEvent() { |
| 121 if (!pending_event_) | 121 if (!pending_event_) |
| 122 return; | 122 return; |
| 123 // JavaScript does not have 64-bit integers. Instead we use double, which | 123 // JavaScript does not have 64-bit integers. Instead we use double, which |
| 124 // is in IEEE 754 formant and accurate up to 52-bits in JS, and in practice | 124 // is in IEEE 754 formant and accurate up to 52-bits in JS, and in practice |
| 125 // in C++. Larger values are rounded. | 125 // in C++. Larger values are rounded. |
| 126 pending_event_->num_total_jobs = drive_jobs_.size(); | 126 pending_event_->num_total_jobs = drive_jobs_.size(); |
| 127 pending_event_->processed.reset(new double(num_completed_bytes_)); | 127 pending_event_->processed = num_completed_bytes_; |
| 128 pending_event_->total.reset(new double(num_total_bytes_)); | 128 pending_event_->total = num_total_bytes_; |
| 129 | 129 |
| 130 BroadcastEvent( | 130 BroadcastEvent( |
| 131 file_manager_private::OnFileTransfersUpdated::kEventName, | 131 file_manager_private::OnFileTransfersUpdated::kEventName, |
| 132 file_manager_private::OnFileTransfersUpdated::Create(*pending_event_)); | 132 file_manager_private::OnFileTransfersUpdated::Create(*pending_event_)); |
| 133 pending_event_.reset(); | 133 pending_event_.reset(); |
| 134 } | 134 } |
| 135 | 135 |
| 136 } // namespace file_manager | 136 } // namespace file_manager |
| OLD | NEW |