| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 if (profile_->GetPrefs()->GetBoolean(prefs::kDisableDrive)) | 158 if (profile_->GetPrefs()->GetBoolean(prefs::kDisableDrive)) |
| 160 return true; | 159 return true; |
| 161 | 160 |
| 162 // Should stop if the network is not online. | 161 // Should stop if the network is not online. |
| 163 if (net::NetworkChangeNotifier::IsOffline()) | 162 if (net::NetworkChangeNotifier::IsOffline()) |
| 164 return true; | 163 return true; |
| 165 | 164 |
| 166 // Should stop if the current connection is on cellular network, and | 165 // Should stop if the current connection is on cellular network, and |
| 167 // fetching is disabled over cellular. | 166 // fetching is disabled over cellular. |
| 168 if (profile_->GetPrefs()->GetBoolean(prefs::kDisableDriveOverCellular) && | 167 if (profile_->GetPrefs()->GetBoolean(prefs::kDisableDriveOverCellular) && |
| 169 util::IsConnectionTypeCellular()) | 168 net::NetworkChangeNotifier::IsConnectionCellular( |
| 169 net::NetworkChangeNotifier::GetConnectionType())) |
| 170 return true; | 170 return true; |
| 171 | 171 |
| 172 return false; | 172 return false; |
| 173 } | 173 } |
| 174 | 174 |
| 175 void DriveScheduler::ThrottleAndContinueJobLoop() { | 175 void DriveScheduler::ThrottleAndContinueJobLoop() { |
| 176 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 176 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 177 | 177 |
| 178 if (throttle_count_ < kMaxThrottleCount) | 178 if (throttle_count_ < kMaxThrottleCount) |
| 179 throttle_count_++; | 179 throttle_count_++; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 236 | 236 |
| 237 // Resume the job loop if the network is back online. Note that we don't | 237 // Resume the job loop if the network is back online. Note that we don't |
| 238 // need to check the type of the network as it will be checked in | 238 // need to check the type of the network as it will be checked in |
| 239 // ShouldStopJobLoop() as soon as the loop is resumed. | 239 // ShouldStopJobLoop() as soon as the loop is resumed. |
| 240 if (!net::NetworkChangeNotifier::IsOffline()) | 240 if (!net::NetworkChangeNotifier::IsOffline()) |
| 241 StartJobLoop(); | 241 StartJobLoop(); |
| 242 } | 242 } |
| 243 | 243 |
| 244 } // namespace drive | 244 } // namespace drive |
| OLD | NEW |