| 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> | |
| 8 #include <vector> | 7 #include <vector> |
| 9 | 8 |
| 10 #include "base/bind.h" | 9 #include "base/bind.h" |
| 11 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| 12 #include "base/prefs/pref_change_registrar.h" | |
| 13 #include "base/prefs/pref_service.h" | |
| 14 #include "chrome/browser/chromeos/drive/drive.pb.h" | 11 #include "chrome/browser/chromeos/drive/drive.pb.h" |
| 15 #include "chrome/browser/chromeos/drive/drive_file_system_interface.h" | 12 #include "chrome/browser/chromeos/drive/drive_file_system_interface.h" |
| 16 #include "chrome/browser/profiles/profile.h" | |
| 17 #include "chrome/common/pref_names.h" | |
| 18 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 19 | 14 |
| 20 using content::BrowserThread; | 15 using content::BrowserThread; |
| 21 | 16 |
| 22 namespace drive { | 17 namespace drive { |
| 23 | 18 |
| 24 namespace { | 19 namespace { |
| 25 | 20 |
| 26 // The delay constant is used to delay processing a sync task. We should not | 21 // The delay constant is used to delay processing a sync task. We should not |
| 27 // process SyncTasks immediately for the following reasons: | 22 // process SyncTasks immediately for the following reasons: |
| (...skipping 23 matching lines...) Expand all Loading... |
| 51 | 46 |
| 52 if (cache_entry.is_pinned() && !cache_entry.is_present()) | 47 if (cache_entry.is_pinned() && !cache_entry.is_present()) |
| 53 to_fetch->push_back(resource_id); | 48 to_fetch->push_back(resource_id); |
| 54 | 49 |
| 55 if (cache_entry.is_dirty()) | 50 if (cache_entry.is_dirty()) |
| 56 to_upload->push_back(resource_id); | 51 to_upload->push_back(resource_id); |
| 57 } | 52 } |
| 58 | 53 |
| 59 } // namespace | 54 } // namespace |
| 60 | 55 |
| 61 DriveSyncClient::DriveSyncClient(Profile* profile, | 56 DriveSyncClient::DriveSyncClient(DriveFileSystemInterface* file_system, |
| 62 DriveFileSystemInterface* file_system, | |
| 63 DriveCache* cache) | 57 DriveCache* cache) |
| 64 : profile_(profile), | 58 : file_system_(file_system), |
| 65 file_system_(file_system), | |
| 66 cache_(cache), | 59 cache_(cache), |
| 67 delay_(base::TimeDelta::FromSeconds(kDelaySeconds)), | 60 delay_(base::TimeDelta::FromSeconds(kDelaySeconds)), |
| 68 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { | 61 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
| 69 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 70 } | 63 } |
| 71 | 64 |
| 72 DriveSyncClient::~DriveSyncClient() { | 65 DriveSyncClient::~DriveSyncClient() { |
| 73 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 74 if (file_system_) | 67 if (file_system_) |
| 75 file_system_->RemoveObserver(this); | 68 file_system_->RemoveObserver(this); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 if (error == DRIVE_FILE_OK) { | 336 if (error == DRIVE_FILE_OK) { |
| 344 DVLOG(1) << "Uploaded " << resource_id; | 337 DVLOG(1) << "Uploaded " << resource_id; |
| 345 } else { | 338 } else { |
| 346 // TODO(satorux): We should re-queue if the error is recoverable. | 339 // TODO(satorux): We should re-queue if the error is recoverable. |
| 347 LOG(WARNING) << "Failed to upload " << resource_id << ": " | 340 LOG(WARNING) << "Failed to upload " << resource_id << ": " |
| 348 << DriveFileErrorToString(error); | 341 << DriveFileErrorToString(error); |
| 349 } | 342 } |
| 350 } | 343 } |
| 351 | 344 |
| 352 } // namespace drive | 345 } // namespace drive |
| OLD | NEW |