| 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_sync_client.h" | 5 #include "chrome/browser/chromeos/drive/drive_sync_client.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/message_loop_proxy.h" | 11 #include "base/message_loop_proxy.h" |
| 12 #include "chrome/browser/api/prefs/pref_change_registrar.h" | 12 #include "chrome/browser/api/prefs/pref_change_registrar.h" |
| 13 #include "chrome/browser/chromeos/drive/drive.pb.h" | 13 #include "chrome/browser/chromeos/drive/drive.pb.h" |
| 14 #include "chrome/browser/chromeos/drive/drive_file_system_interface.h" | 14 #include "chrome/browser/chromeos/drive/drive_file_system_interface.h" |
| 15 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" | |
| 16 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 19 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 19 #include "net/base/network_change_notifier.h" |
| 20 | 20 |
| 21 using content::BrowserThread; | 21 using content::BrowserThread; |
| 22 | 22 |
| 23 namespace drive { | 23 namespace drive { |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 // The delay constant is used to delay processing a SyncTask in | 27 // The delay constant is used to delay processing a SyncTask in |
| 28 // DoSyncLoop(). We should not process SyncTasks immediately for the | 28 // DoSyncLoop(). We should not process SyncTasks immediately for the |
| 29 // following reasons: | 29 // following reasons: |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 if (profile_->GetPrefs()->GetBoolean(prefs::kDisableGData)) | 188 if (profile_->GetPrefs()->GetBoolean(prefs::kDisableGData)) |
| 189 return true; | 189 return true; |
| 190 | 190 |
| 191 // Should stop if the network is not online. | 191 // Should stop if the network is not online. |
| 192 if (net::NetworkChangeNotifier::IsOffline()) | 192 if (net::NetworkChangeNotifier::IsOffline()) |
| 193 return true; | 193 return true; |
| 194 | 194 |
| 195 // Should stop if the current connection is on cellular network, and | 195 // Should stop if the current connection is on cellular network, and |
| 196 // fetching is disabled over cellular. | 196 // fetching is disabled over cellular. |
| 197 if (profile_->GetPrefs()->GetBoolean(prefs::kDisableGDataOverCellular) && | 197 if (profile_->GetPrefs()->GetBoolean(prefs::kDisableGDataOverCellular) && |
| 198 util::IsConnectionTypeCellular()) | 198 net::NetworkChangeNotifier::IsConnectionCellular()) |
| 199 return true; | 199 return true; |
| 200 | 200 |
| 201 return false; | 201 return false; |
| 202 } | 202 } |
| 203 | 203 |
| 204 void DriveSyncClient::OnInitialLoadFinished(DriveFileError error) { | 204 void DriveSyncClient::OnInitialLoadFinished(DriveFileError error) { |
| 205 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 205 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 206 | 206 |
| 207 StartProcessingBacklog(); | 207 StartProcessingBacklog(); |
| 208 } | 208 } |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 429 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 430 | 430 |
| 431 // Resume the sync loop if the network is back online. Note that we don't | 431 // Resume the sync loop if the network is back online. Note that we don't |
| 432 // need to check the type of the network as it will be checked in | 432 // need to check the type of the network as it will be checked in |
| 433 // ShouldStopSyncLoop() as soon as the loop is resumed. | 433 // ShouldStopSyncLoop() as soon as the loop is resumed. |
| 434 if (!net::NetworkChangeNotifier::IsOffline()) | 434 if (!net::NetworkChangeNotifier::IsOffline()) |
| 435 StartSyncLoop(); | 435 StartSyncLoop(); |
| 436 } | 436 } |
| 437 | 437 |
| 438 } // namespace drive | 438 } // namespace drive |
| OLD | NEW |