| 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> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> |
| 11 #include <set> | 12 #include <set> |
| 12 #include <string> | 13 #include <string> |
| 13 | 14 |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/memory/linked_ptr.h" | 16 #include "base/memory/linked_ptr.h" |
| 16 #include "base/memory/scoped_ptr.h" | |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/threading/thread_checker.h" | 18 #include "base/threading/thread_checker.h" |
| 19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 20 #include "base/values.h" | 20 #include "base/values.h" |
| 21 #include "chrome/common/extensions/api/file_manager_private.h" | 21 #include "chrome/common/extensions/api/file_manager_private.h" |
| 22 #include "components/drive/job_list.h" | 22 #include "components/drive/job_list.h" |
| 23 #include "extensions/browser/extension_event_histogram_value.h" | 23 #include "extensions/browser/extension_event_histogram_value.h" |
| 24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 25 | 25 |
| 26 namespace file_manager { | 26 namespace file_manager { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 45 // Helper method for converting drive path to file system url. | 45 // Helper method for converting drive path to file system url. |
| 46 virtual GURL ConvertDrivePathToFileSystemUrl( | 46 virtual GURL ConvertDrivePathToFileSystemUrl( |
| 47 const base::FilePath& file_path, | 47 const base::FilePath& file_path, |
| 48 const std::string& extension_id) = 0; | 48 const std::string& extension_id) = 0; |
| 49 | 49 |
| 50 // Helper method for dispatching an event to an extension. | 50 // Helper method for dispatching an event to an extension. |
| 51 virtual void DispatchEventToExtension( | 51 virtual void DispatchEventToExtension( |
| 52 const std::string& extension_id, | 52 const std::string& extension_id, |
| 53 extensions::events::HistogramValue histogram_value, | 53 extensions::events::HistogramValue histogram_value, |
| 54 const std::string& event_name, | 54 const std::string& event_name, |
| 55 scoped_ptr<base::ListValue> event_args) = 0; | 55 std::unique_ptr<base::ListValue> event_args) = 0; |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 // Request sending transfer event with |job_info| and |state|. | 58 // Request sending transfer event with |job_info| and |state|. |
| 59 // If |immediate| is true, the event will be dispatched synchronously. | 59 // If |immediate| is true, the event will be dispatched synchronously. |
| 60 // Otherwise, the event is throttled, or may be skipped. | 60 // Otherwise, the event is throttled, or may be skipped. |
| 61 void ScheduleDriveFileTransferEvent( | 61 void ScheduleDriveFileTransferEvent( |
| 62 const drive::JobInfo& job_info, | 62 const drive::JobInfo& job_info, |
| 63 extensions::api::file_manager_private::TransferState state, | 63 extensions::api::file_manager_private::TransferState state, |
| 64 bool immediate); | 64 bool immediate); |
| 65 | 65 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 79 const int64_t num_total_bytes); | 79 const int64_t num_total_bytes); |
| 80 | 80 |
| 81 // Delay time before sending progress events. | 81 // Delay time before sending progress events. |
| 82 base::TimeDelta event_delay_; | 82 base::TimeDelta event_delay_; |
| 83 | 83 |
| 84 // Set of job that are in the job schedular. | 84 // Set of job that are in the job schedular. |
| 85 std::map<drive::JobID, linked_ptr<drive::JobInfo>> drive_jobs_; | 85 std::map<drive::JobID, linked_ptr<drive::JobInfo>> drive_jobs_; |
| 86 | 86 |
| 87 // Job info of pending event. |ScheduleDriveFileTransferEvent| registers | 87 // Job info of pending event. |ScheduleDriveFileTransferEvent| registers |
| 88 // timeout callback to dispatch this. | 88 // timeout callback to dispatch this. |
| 89 scoped_ptr<drive::JobInfo> pending_job_info_; | 89 std::unique_ptr<drive::JobInfo> pending_job_info_; |
| 90 | 90 |
| 91 // Transfer state of pending event. | 91 // Transfer state of pending event. |
| 92 extensions::api::file_manager_private::TransferState pending_state_; | 92 extensions::api::file_manager_private::TransferState pending_state_; |
| 93 | 93 |
| 94 // Computed bytes of tasks that have been processed. Once it completes all | 94 // Computed bytes of tasks that have been processed. Once it completes all |
| 95 // tasks, it clears the variable. | 95 // tasks, it clears the variable. |
| 96 int64_t num_completed_bytes_; | 96 int64_t num_completed_bytes_; |
| 97 | 97 |
| 98 // Total bytes of tasks that have been processed. Once it completes all tasks, | 98 // Total bytes of tasks that have been processed. Once it completes all tasks, |
| 99 // it clears the variable. | 99 // it clears the variable. |
| 100 int64_t num_total_bytes_; | 100 int64_t num_total_bytes_; |
| 101 | 101 |
| 102 // Thread checker. | 102 // Thread checker. |
| 103 base::ThreadChecker thread_checker_; | 103 base::ThreadChecker thread_checker_; |
| 104 | 104 |
| 105 // Note: This should remain the last member so it'll be destroyed and | 105 // Note: This should remain the last member so it'll be destroyed and |
| 106 // invalidate the weak pointers before any other members are destroyed. | 106 // invalidate the weak pointers before any other members are destroyed. |
| 107 base::WeakPtrFactory<JobEventRouter> weak_factory_; | 107 base::WeakPtrFactory<JobEventRouter> weak_factory_; |
| 108 | 108 |
| 109 DISALLOW_COPY_AND_ASSIGN(JobEventRouter); | 109 DISALLOW_COPY_AND_ASSIGN(JobEventRouter); |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 } // namespace file_manager | 112 } // namespace file_manager |
| 113 | 113 |
| 114 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_JOB_EVENT_ROUTER_H_ | 114 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_JOB_EVENT_ROUTER_H_ |
| OLD | NEW |