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