OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_DRIVE_JOB_SCHEDULER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_JOB_SCHEDULER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_JOB_SCHEDULER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_JOB_SCHEDULER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/id_map.h" | 10 #include "base/id_map.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // On offline case, no jobs run. USER_INITIATED jobs fail immediately. | 59 // On offline case, no jobs run. USER_INITIATED jobs fail immediately. |
60 // BACKGROUND jobs stay in the queue and wait for network connection. | 60 // BACKGROUND jobs stay in the queue and wait for network connection. |
61 class JobScheduler | 61 class JobScheduler |
62 : public net::NetworkChangeNotifier::ConnectionTypeObserver, | 62 : public net::NetworkChangeNotifier::ConnectionTypeObserver, |
63 public JobListInterface { | 63 public JobListInterface { |
64 public: | 64 public: |
65 JobScheduler(PrefService* pref_service, | 65 JobScheduler(PrefService* pref_service, |
66 EventLogger* logger, | 66 EventLogger* logger, |
67 DriveServiceInterface* drive_service, | 67 DriveServiceInterface* drive_service, |
68 base::SequencedTaskRunner* blocking_task_runner); | 68 base::SequencedTaskRunner* blocking_task_runner); |
69 virtual ~JobScheduler(); | 69 ~JobScheduler() override; |
70 | 70 |
71 // JobListInterface overrides. | 71 // JobListInterface overrides. |
72 virtual std::vector<JobInfo> GetJobInfoList() override; | 72 std::vector<JobInfo> GetJobInfoList() override; |
73 virtual void AddObserver(JobListObserver* observer) override; | 73 void AddObserver(JobListObserver* observer) override; |
74 virtual void RemoveObserver(JobListObserver* observer) override; | 74 void RemoveObserver(JobListObserver* observer) override; |
75 virtual void CancelJob(JobID job_id) override; | 75 void CancelJob(JobID job_id) override; |
76 virtual void CancelAllJobs() override; | 76 void CancelAllJobs() override; |
77 | 77 |
78 // Adds a GetAppList operation to the queue. | 78 // Adds a GetAppList operation to the queue. |
79 // |callback| must not be null. | 79 // |callback| must not be null. |
80 void GetAppList(const google_apis::AppListCallback& callback); | 80 void GetAppList(const google_apis::AppListCallback& callback); |
81 | 81 |
82 // Adds a GetAboutResource operation to the queue. | 82 // Adds a GetAboutResource operation to the queue. |
83 // |callback| must not be null. | 83 // |callback| must not be null. |
84 void GetAboutResource(const google_apis::AboutResourceCallback& callback); | 84 void GetAboutResource(const google_apis::AboutResourceCallback& callback); |
85 | 85 |
86 // Adds a GetAllFileList operation to the queue. | 86 // Adds a GetAllFileList operation to the queue. |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 const base::Callback<google_apis::CancelCallback()>& original_task, | 334 const base::Callback<google_apis::CancelCallback()>& original_task, |
335 const google_apis::FileResourceCallback& callback, | 335 const google_apis::FileResourceCallback& callback, |
336 google_apis::GDataErrorCode error, | 336 google_apis::GDataErrorCode error, |
337 const GURL& upload_location, | 337 const GURL& upload_location, |
338 scoped_ptr<google_apis::FileResource> entry); | 338 scoped_ptr<google_apis::FileResource> entry); |
339 | 339 |
340 // Updates the progress status of the specified job. | 340 // Updates the progress status of the specified job. |
341 void UpdateProgress(JobID job_id, int64 progress, int64 total); | 341 void UpdateProgress(JobID job_id, int64 progress, int64 total); |
342 | 342 |
343 // net::NetworkChangeNotifier::ConnectionTypeObserver override. | 343 // net::NetworkChangeNotifier::ConnectionTypeObserver override. |
344 virtual void OnConnectionTypeChanged( | 344 void OnConnectionTypeChanged( |
345 net::NetworkChangeNotifier::ConnectionType type) override; | 345 net::NetworkChangeNotifier::ConnectionType type) override; |
346 | 346 |
347 // Get the type of queue the specified job should be put in. | 347 // Get the type of queue the specified job should be put in. |
348 QueueType GetJobQueueType(JobType type); | 348 QueueType GetJobQueueType(JobType type); |
349 | 349 |
350 // For testing only. Disables throttling so that testing is faster. | 350 // For testing only. Disables throttling so that testing is faster. |
351 void SetDisableThrottling(bool disable) { disable_throttling_ = disable; } | 351 void SetDisableThrottling(bool disable) { disable_throttling_ = disable; } |
352 | 352 |
353 // Aborts a job which is not in STATE_RUNNING. | 353 // Aborts a job which is not in STATE_RUNNING. |
354 void AbortNotRunningJob(JobEntry* job, google_apis::GDataErrorCode error); | 354 void AbortNotRunningJob(JobEntry* job, google_apis::GDataErrorCode error); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 | 395 |
396 // Note: This should remain the last member so it'll be destroyed and | 396 // Note: This should remain the last member so it'll be destroyed and |
397 // invalidate its weak pointers before any other members are destroyed. | 397 // invalidate its weak pointers before any other members are destroyed. |
398 base::WeakPtrFactory<JobScheduler> weak_ptr_factory_; | 398 base::WeakPtrFactory<JobScheduler> weak_ptr_factory_; |
399 DISALLOW_COPY_AND_ASSIGN(JobScheduler); | 399 DISALLOW_COPY_AND_ASSIGN(JobScheduler); |
400 }; | 400 }; |
401 | 401 |
402 } // namespace drive | 402 } // namespace drive |
403 | 403 |
404 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_JOB_SCHEDULER_H_ | 404 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_JOB_SCHEDULER_H_ |
OLD | NEW |