| 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" |
| 18 | 17 |
| 19 using content::BrowserThread; | 18 using content::BrowserThread; |
| 20 | 19 |
| 21 namespace drive { | 20 namespace drive { |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 if (profile_->GetPrefs()->GetBoolean(prefs::kDisableGData)) | 152 if (profile_->GetPrefs()->GetBoolean(prefs::kDisableGData)) |
| 154 return true; | 153 return true; |
| 155 | 154 |
| 156 // Should stop if the network is not online. | 155 // Should stop if the network is not online. |
| 157 if (net::NetworkChangeNotifier::IsOffline()) | 156 if (net::NetworkChangeNotifier::IsOffline()) |
| 158 return true; | 157 return true; |
| 159 | 158 |
| 160 // Should stop if the current connection is on cellular network, and | 159 // Should stop if the current connection is on cellular network, and |
| 161 // fetching is disabled over cellular. | 160 // fetching is disabled over cellular. |
| 162 if (profile_->GetPrefs()->GetBoolean(prefs::kDisableGDataOverCellular) && | 161 if (profile_->GetPrefs()->GetBoolean(prefs::kDisableGDataOverCellular) && |
| 163 util::IsConnectionTypeCellular()) | 162 net::NetworkChangeNotifier::IsConnectionCellular( |
| 163 net::NetworkChangeNotifier::GetConnectionType())) |
| 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 |