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 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_JOB_EVENT_ROUTER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_JOB_EVENT_ROUTER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_JOB_EVENT_ROUTER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_JOB_EVENT_ROUTER_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <map> | 10 #include <map> |
9 #include <set> | 11 #include <set> |
10 #include <string> | 12 #include <string> |
11 | 13 |
| 14 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
14 #include "base/threading/thread_checker.h" | 17 #include "base/threading/thread_checker.h" |
15 #include "base/time/time.h" | 18 #include "base/time/time.h" |
16 #include "base/values.h" | 19 #include "base/values.h" |
17 #include "chrome/common/extensions/api/file_manager_private.h" | 20 #include "chrome/common/extensions/api/file_manager_private.h" |
18 #include "components/drive/job_list.h" | 21 #include "components/drive/job_list.h" |
19 #include "extensions/browser/extension_event_histogram_value.h" | 22 #include "extensions/browser/extension_event_histogram_value.h" |
20 #include "url/gurl.h" | 23 #include "url/gurl.h" |
21 | 24 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 void SendDriveFileTransferEvent(); | 66 void SendDriveFileTransferEvent(); |
64 | 67 |
65 // Update |num_completed_bytes_| and |num_total_bytes_| depends on |job|. | 68 // Update |num_completed_bytes_| and |num_total_bytes_| depends on |job|. |
66 void UpdateBytes(const drive::JobInfo& job_info); | 69 void UpdateBytes(const drive::JobInfo& job_info); |
67 | 70 |
68 // Dispatches FileTransfersUpdate event to an extension. | 71 // Dispatches FileTransfersUpdate event to an extension. |
69 void DispatchFileTransfersUpdateEventToExtension( | 72 void DispatchFileTransfersUpdateEventToExtension( |
70 const std::string& extension_id, | 73 const std::string& extension_id, |
71 const drive::JobInfo& job_info, | 74 const drive::JobInfo& job_info, |
72 const extensions::api::file_manager_private::TransferState& state, | 75 const extensions::api::file_manager_private::TransferState& state, |
73 const int64 num_total_jobs, | 76 const int64_t num_total_jobs, |
74 const int64 num_completed_bytes, | 77 const int64_t num_completed_bytes, |
75 const int64 num_total_bytes); | 78 const int64_t num_total_bytes); |
76 | 79 |
77 // Delay time before sending progress events. | 80 // Delay time before sending progress events. |
78 base::TimeDelta event_delay_; | 81 base::TimeDelta event_delay_; |
79 | 82 |
80 // Set of job that are in the job schedular. | 83 // Set of job that are in the job schedular. |
81 std::map<drive::JobID, linked_ptr<drive::JobInfo>> drive_jobs_; | 84 std::map<drive::JobID, linked_ptr<drive::JobInfo>> drive_jobs_; |
82 | 85 |
83 // Job info of pending event. |ScheduleDriveFileTransferEvent| registers | 86 // Job info of pending event. |ScheduleDriveFileTransferEvent| registers |
84 // timeout callback to dispatch this. | 87 // timeout callback to dispatch this. |
85 scoped_ptr<drive::JobInfo> pending_job_info_; | 88 scoped_ptr<drive::JobInfo> pending_job_info_; |
86 | 89 |
87 // Transfer state of pending event. | 90 // Transfer state of pending event. |
88 extensions::api::file_manager_private::TransferState pending_state_; | 91 extensions::api::file_manager_private::TransferState pending_state_; |
89 | 92 |
90 // Computed bytes of tasks that have been processed. Once it completes all | 93 // Computed bytes of tasks that have been processed. Once it completes all |
91 // tasks, it clears the variable. | 94 // tasks, it clears the variable. |
92 int64 num_completed_bytes_; | 95 int64_t num_completed_bytes_; |
93 | 96 |
94 // Total bytes of tasks that have been processed. Once it completes all tasks, | 97 // Total bytes of tasks that have been processed. Once it completes all tasks, |
95 // it clears the variable. | 98 // it clears the variable. |
96 int64 num_total_bytes_; | 99 int64_t num_total_bytes_; |
97 | 100 |
98 // Thread checker. | 101 // Thread checker. |
99 base::ThreadChecker thread_checker_; | 102 base::ThreadChecker thread_checker_; |
100 | 103 |
101 // Note: This should remain the last member so it'll be destroyed and | 104 // Note: This should remain the last member so it'll be destroyed and |
102 // invalidate the weak pointers before any other members are destroyed. | 105 // invalidate the weak pointers before any other members are destroyed. |
103 base::WeakPtrFactory<JobEventRouter> weak_factory_; | 106 base::WeakPtrFactory<JobEventRouter> weak_factory_; |
104 | 107 |
105 DISALLOW_COPY_AND_ASSIGN(JobEventRouter); | 108 DISALLOW_COPY_AND_ASSIGN(JobEventRouter); |
106 }; | 109 }; |
107 | 110 |
108 } // namespace file_manager | 111 } // namespace file_manager |
109 | 112 |
110 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_JOB_EVENT_ROUTER_H_ | 113 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_JOB_EVENT_ROUTER_H_ |
OLD | NEW |