| 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/gdata/drive_file_system.h" | 5 #include "chrome/browser/chromeos/gdata/drive_file_system.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/json/json_file_value_serializer.h" | 12 #include "base/json/json_file_value_serializer.h" |
| 13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 14 #include "base/message_loop_proxy.h" | 14 #include "base/message_loop_proxy.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/platform_file.h" | 16 #include "base/platform_file.h" |
| 17 #include "base/threading/sequenced_worker_pool.h" | 17 #include "base/threading/sequenced_worker_pool.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "chrome/browser/chromeos/gdata/drive.pb.h" | 19 #include "chrome/browser/chromeos/gdata/drive.pb.h" |
| 20 #include "chrome/browser/chromeos/gdata/drive_api_parser.h" | 20 #include "chrome/browser/chromeos/gdata/drive_api_parser.h" |
| 21 #include "chrome/browser/chromeos/gdata/drive_files.h" | 21 #include "chrome/browser/chromeos/gdata/drive_files.h" |
| 22 #include "chrome/browser/chromeos/gdata/drive_service_interface.h" | 22 #include "chrome/browser/chromeos/gdata/drive_service_interface.h" |
| 23 #include "chrome/browser/chromeos/gdata/drive_system_service.h" |
| 23 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" | 24 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" |
| 24 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h" | 25 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h" |
| 25 #include "chrome/browser/chromeos/gdata/gdata_protocol_handler.h" | 26 #include "chrome/browser/chromeos/gdata/gdata_protocol_handler.h" |
| 26 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" | |
| 27 #include "chrome/browser/chromeos/gdata/gdata_uploader.h" | 27 #include "chrome/browser/chromeos/gdata/gdata_uploader.h" |
| 28 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 28 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
| 29 #include "chrome/browser/chromeos/gdata/task_util.h" | 29 #include "chrome/browser/chromeos/gdata/task_util.h" |
| 30 #include "chrome/browser/prefs/pref_service.h" | 30 #include "chrome/browser/prefs/pref_service.h" |
| 31 #include "chrome/browser/profiles/profile.h" | 31 #include "chrome/browser/profiles/profile.h" |
| 32 #include "chrome/common/chrome_notification_types.h" | 32 #include "chrome/common/chrome_notification_types.h" |
| 33 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
| 34 #include "content/public/browser/browser_thread.h" | 34 #include "content/public/browser/browser_thread.h" |
| 35 #include "content/public/browser/notification_details.h" | 35 #include "content/public/browser/notification_details.h" |
| 36 #include "net/base/mime_util.h" | 36 #include "net/base/mime_util.h" |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 | 467 |
| 468 void DriveFileSystem::OnUpdateChecked(ContentOrigin initial_origin, | 468 void DriveFileSystem::OnUpdateChecked(ContentOrigin initial_origin, |
| 469 DriveFileError error) { | 469 DriveFileError error) { |
| 470 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 470 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 471 | 471 |
| 472 if (error != DRIVE_FILE_OK) | 472 if (error != DRIVE_FILE_OK) |
| 473 resource_metadata_->set_origin(initial_origin); | 473 resource_metadata_->set_origin(initial_origin); |
| 474 } | 474 } |
| 475 | 475 |
| 476 DriveFileSystem::~DriveFileSystem() { | 476 DriveFileSystem::~DriveFileSystem() { |
| 477 // This should be called from UI thread, from GDataSystemService shutdown. | 477 // This should be called from UI thread, from DriveSystemService shutdown. |
| 478 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 478 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 479 | 479 |
| 480 feed_loader_->RemoveObserver(this); | 480 feed_loader_->RemoveObserver(this); |
| 481 | 481 |
| 482 // Cancel all the in-flight operations. | 482 // Cancel all the in-flight operations. |
| 483 // This asynchronously cancels the URL fetch operations. | 483 // This asynchronously cancels the URL fetch operations. |
| 484 drive_service_->CancelAll(); | 484 drive_service_->CancelAll(); |
| 485 } | 485 } |
| 486 | 486 |
| 487 void DriveFileSystem::AddObserver( | 487 void DriveFileSystem::AddObserver( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 504 base::TimeDelta::FromSeconds( | 504 base::TimeDelta::FromSeconds( |
| 505 kGDataUpdateCheckIntervalInSec), | 505 kGDataUpdateCheckIntervalInSec), |
| 506 base::Bind(&DriveFileSystem::CheckForUpdates, | 506 base::Bind(&DriveFileSystem::CheckForUpdates, |
| 507 ui_weak_ptr_)); | 507 ui_weak_ptr_)); |
| 508 } | 508 } |
| 509 | 509 |
| 510 void DriveFileSystem::StopUpdates() { | 510 void DriveFileSystem::StopUpdates() { |
| 511 // If unmount request comes from filesystem side, this method may be called | 511 // If unmount request comes from filesystem side, this method may be called |
| 512 // twice. First is just after unmounting on filesystem, second is after | 512 // twice. First is just after unmounting on filesystem, second is after |
| 513 // unmounting on filemanager on JS. In other words, if this is called from | 513 // unmounting on filemanager on JS. In other words, if this is called from |
| 514 // GDataSystemService::RemoveDriveMountPoint(), this will be called again from | 514 // DriveSystemService::RemoveDriveMountPoint(), this will be called again from |
| 515 // FileBrowserEventRouter::HandleRemoteUpdateRequestOnUIThread(). | 515 // FileBrowserEventRouter::HandleRemoteUpdateRequestOnUIThread(). |
| 516 // We choose to stopping updates asynchronous without waiting for filemanager, | 516 // We choose to stopping updates asynchronous without waiting for filemanager, |
| 517 // rather than waiting for completion of unmounting on filemanager. | 517 // rather than waiting for completion of unmounting on filemanager. |
| 518 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 518 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 519 if (update_timer_.IsRunning()) | 519 if (update_timer_.IsRunning()) |
| 520 update_timer_.Stop(); | 520 update_timer_.Stop(); |
| 521 } | 521 } |
| 522 | 522 |
| 523 void DriveFileSystem::GetEntryInfoByResourceId( | 523 void DriveFileSystem::GetEntryInfoByResourceId( |
| 524 const std::string& resource_id, | 524 const std::string& resource_id, |
| (...skipping 2780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3305 return; | 3305 return; |
| 3306 } | 3306 } |
| 3307 | 3307 |
| 3308 PlatformFileInfoProto entry_file_info; | 3308 PlatformFileInfoProto entry_file_info; |
| 3309 DriveEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); | 3309 DriveEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); |
| 3310 *entry_proto->mutable_file_info() = entry_file_info; | 3310 *entry_proto->mutable_file_info() = entry_file_info; |
| 3311 callback.Run(DRIVE_FILE_OK, entry_proto.Pass()); | 3311 callback.Run(DRIVE_FILE_OK, entry_proto.Pass()); |
| 3312 } | 3312 } |
| 3313 | 3313 |
| 3314 } // namespace gdata | 3314 } // namespace gdata |
| OLD | NEW |