| 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 #include "chrome/browser/chromeos/drive/drive_scheduler.h" | 5 #include "chrome/browser/chromeos/drive/drive_scheduler.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| 11 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" | |
| 12 #include "chrome/browser/chromeos/drive/file_system/drive_operations.h" | 11 #include "chrome/browser/chromeos/drive/file_system/drive_operations.h" |
| 13 #include "chrome/browser/chromeos/drive/file_system/remove_operation.h" | 12 #include "chrome/browser/chromeos/drive/file_system/remove_operation.h" |
| 14 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 17 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 #include "net/base/network_change_notifier.h" |
| 18 | 18 |
| 19 using content::BrowserThread; | 19 using content::BrowserThread; |
| 20 | 20 |
| 21 namespace drive { | 21 namespace drive { |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 const int kMaxThrottleCount = 5; | 24 const int kMaxThrottleCount = 5; |
| 25 } | 25 } |
| 26 | 26 |
| 27 DriveScheduler::JobInfo::JobInfo(JobType in_job_type, FilePath in_file_path) | 27 DriveScheduler::JobInfo::JobInfo(JobType in_job_type, FilePath in_file_path) |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 if (profile_->GetPrefs()->GetBoolean(prefs::kDisableGData)) | 153 if (profile_->GetPrefs()->GetBoolean(prefs::kDisableGData)) |
| 154 return true; | 154 return true; |
| 155 | 155 |
| 156 // Should stop if the network is not online. | 156 // Should stop if the network is not online. |
| 157 if (net::NetworkChangeNotifier::IsOffline()) | 157 if (net::NetworkChangeNotifier::IsOffline()) |
| 158 return true; | 158 return true; |
| 159 | 159 |
| 160 // Should stop if the current connection is on cellular network, and | 160 // Should stop if the current connection is on cellular network, and |
| 161 // fetching is disabled over cellular. | 161 // fetching is disabled over cellular. |
| 162 if (profile_->GetPrefs()->GetBoolean(prefs::kDisableGDataOverCellular) && | 162 if (profile_->GetPrefs()->GetBoolean(prefs::kDisableGDataOverCellular) && |
| 163 util::IsConnectionTypeCellular()) | 163 net::NetworkChangeNotifier::IsConnectionCellular()) |
| 164 return true; | 164 return true; |
| 165 | 165 |
| 166 return false; | 166 return false; |
| 167 } | 167 } |
| 168 | 168 |
| 169 void DriveScheduler::ThrottleAndContinueJobLoop() { | 169 void DriveScheduler::ThrottleAndContinueJobLoop() { |
| 170 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 170 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 171 | 171 |
| 172 if (throttle_count_ < kMaxThrottleCount) | 172 if (throttle_count_ < kMaxThrottleCount) |
| 173 throttle_count_++; | 173 throttle_count_++; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 229 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 230 | 230 |
| 231 // Resume the job loop if the network is back online. Note that we don't | 231 // Resume the job loop if the network is back online. Note that we don't |
| 232 // need to check the type of the network as it will be checked in | 232 // need to check the type of the network as it will be checked in |
| 233 // ShouldStopJobLoop() as soon as the loop is resumed. | 233 // ShouldStopJobLoop() as soon as the loop is resumed. |
| 234 if (!net::NetworkChangeNotifier::IsOffline()) | 234 if (!net::NetworkChangeNotifier::IsOffline()) |
| 235 StartJobLoop(); | 235 StartJobLoop(); |
| 236 } | 236 } |
| 237 | 237 |
| 238 } // namespace drive | 238 } // namespace drive |
| OLD | NEW |