| 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/gdata_file_system.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_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/documents_service_interface.h" |
| 19 #include "chrome/browser/chromeos/gdata/drive_api_parser.h" | 20 #include "chrome/browser/chromeos/gdata/drive_api_parser.h" |
| 20 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" | 21 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" |
| 21 #include "chrome/browser/chromeos/gdata/gdata.pb.h" | 22 #include "chrome/browser/chromeos/gdata/gdata.pb.h" |
| 22 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h" | |
| 23 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h" | 23 #include "chrome/browser/chromeos/gdata/gdata_download_observer.h" |
| 24 #include "chrome/browser/chromeos/gdata/gdata_files.h" | 24 #include "chrome/browser/chromeos/gdata/gdata_files.h" |
| 25 #include "chrome/browser/chromeos/gdata/gdata_protocol_handler.h" | 25 #include "chrome/browser/chromeos/gdata/gdata_protocol_handler.h" |
| 26 #include "chrome/browser/chromeos/gdata/gdata_system_service.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/prefs/pref_service.h" | 29 #include "chrome/browser/prefs/pref_service.h" |
| 30 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
| 31 #include "chrome/common/chrome_notification_types.h" | 31 #include "chrome/common/chrome_notification_types.h" |
| 32 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
| (...skipping 2201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2234 RunTaskOnUIThread(base::Bind(&GDataFileSystem::GetAvailableSpaceOnUIThread, | 2234 RunTaskOnUIThread(base::Bind(&GDataFileSystem::GetAvailableSpaceOnUIThread, |
| 2235 ui_weak_ptr_, | 2235 ui_weak_ptr_, |
| 2236 CreateRelayCallback(callback))); | 2236 CreateRelayCallback(callback))); |
| 2237 } | 2237 } |
| 2238 | 2238 |
| 2239 void GDataFileSystem::GetAvailableSpaceOnUIThread( | 2239 void GDataFileSystem::GetAvailableSpaceOnUIThread( |
| 2240 const GetAvailableSpaceCallback& callback) { | 2240 const GetAvailableSpaceCallback& callback) { |
| 2241 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2241 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2242 DCHECK(!callback.is_null()); | 2242 DCHECK(!callback.is_null()); |
| 2243 | 2243 |
| 2244 if (gdata::util::IsDriveV2ApiEnabled()) { | 2244 documents_service_->GetAccountMetadata( |
| 2245 documents_service_->GetAboutResource( | 2245 gdata::util::IsDriveV2ApiEnabled() ? |
| 2246 base::Bind(&GDataFileSystem::OnGetAboutResource, | 2246 base::Bind(&GDataFileSystem::OnGetAboutResource, |
| 2247 ui_weak_ptr_, | 2247 ui_weak_ptr_, |
| 2248 callback)); | 2248 callback) : |
| 2249 return; | |
| 2250 } | |
| 2251 | |
| 2252 documents_service_->GetAccountMetadata( | |
| 2253 base::Bind(&GDataFileSystem::OnGetAvailableSpace, | 2249 base::Bind(&GDataFileSystem::OnGetAvailableSpace, |
| 2254 ui_weak_ptr_, | 2250 ui_weak_ptr_, |
| 2255 callback)); | 2251 callback)); |
| 2256 } | 2252 } |
| 2257 | 2253 |
| 2258 void GDataFileSystem::OnGetAvailableSpace( | 2254 void GDataFileSystem::OnGetAvailableSpace( |
| 2259 const GetAvailableSpaceCallback& callback, | 2255 const GetAvailableSpaceCallback& callback, |
| 2260 GDataErrorCode status, | 2256 GDataErrorCode status, |
| 2261 scoped_ptr<base::Value> data) { | 2257 scoped_ptr<base::Value> data) { |
| 2262 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2258 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3442 return; | 3438 return; |
| 3443 } | 3439 } |
| 3444 | 3440 |
| 3445 PlatformFileInfoProto entry_file_info; | 3441 PlatformFileInfoProto entry_file_info; |
| 3446 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); | 3442 GDataEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); |
| 3447 *entry_proto->mutable_file_info() = entry_file_info; | 3443 *entry_proto->mutable_file_info() = entry_file_info; |
| 3448 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); | 3444 callback.Run(GDATA_FILE_OK, entry_proto.Pass()); |
| 3449 } | 3445 } |
| 3450 | 3446 |
| 3451 } // namespace gdata | 3447 } // namespace gdata |
| OLD | NEW |