| 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_file_system.h" | 5 #include "chrome/browser/chromeos/drive/drive_file_system.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/json/json_file_value_serializer.h" | 9 #include "base/json/json_file_value_serializer.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
| 36 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
| 37 #include "content/public/browser/notification_details.h" | 37 #include "content/public/browser/notification_details.h" |
| 38 #include "net/base/mime_util.h" | 38 #include "net/base/mime_util.h" |
| 39 | 39 |
| 40 using content::BrowserThread; | 40 using content::BrowserThread; |
| 41 | 41 |
| 42 namespace drive { | 42 namespace drive { |
| 43 namespace { | 43 namespace { |
| 44 | 44 |
| 45 // The resource ID for the root directory for WAPI is defined in the spec: |
| 46 // https://developers.google.com/google-apps/documents-list/ |
| 47 // Note that this special ID only applies to WAPI. Drive uses a non-constant |
| 48 // unique ID given in About resource. |
| 49 const char kWAPIRootDirectoryResourceId[] = "folder:root"; |
| 50 |
| 45 const char kMimeTypeJson[] = "application/json"; | 51 const char kMimeTypeJson[] = "application/json"; |
| 46 const char kEmptyFilePath[] = "/dev/null"; | 52 const char kEmptyFilePath[] = "/dev/null"; |
| 47 | 53 |
| 48 // Drive update polling interval for polling only mode (in seconds). | 54 // Drive update polling interval for polling only mode (in seconds). |
| 49 const int kFastPollingIntervalInSec = 60; | 55 const int kFastPollingIntervalInSec = 60; |
| 50 | 56 |
| 51 // Drive update polling interval when update notification is available (in | 57 // Drive update polling interval when update notification is available (in |
| 52 // seconds). Ideally we don't need this, but we do polling in case update | 58 // seconds). Ideally we don't need this, but we do polling in case update |
| 53 // notification doesn't work. http://crbug.com/157080 | 59 // notification doesn't work. http://crbug.com/157080 |
| 54 const int kSlowPollingIntervalInSec = 300; | 60 const int kSlowPollingIntervalInSec = 300; |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 // Should be created from the file browser extension API on UI thread. | 391 // Should be created from the file browser extension API on UI thread. |
| 386 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 392 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 387 } | 393 } |
| 388 | 394 |
| 389 void DriveFileSystem::Initialize() { | 395 void DriveFileSystem::Initialize() { |
| 390 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 396 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 391 | 397 |
| 392 drive_service_->Initialize(profile_); | 398 drive_service_->Initialize(profile_); |
| 393 | 399 |
| 394 resource_metadata_.reset(new DriveResourceMetadata); | 400 resource_metadata_.reset(new DriveResourceMetadata); |
| 401 if (!google_apis::util::IsDriveV2ApiEnabled()) |
| 402 resource_metadata_->InitializeRootEntry(kWAPIRootDirectoryResourceId); |
| 403 // If Drive API is enabled, the root directory is initialized after |
| 404 // About resource is obtained. |
| 395 feed_loader_.reset(new DriveFeedLoader(resource_metadata_.get(), | 405 feed_loader_.reset(new DriveFeedLoader(resource_metadata_.get(), |
| 396 drive_service_, | 406 drive_service_, |
| 397 webapps_registry_, | 407 webapps_registry_, |
| 398 cache_, | 408 cache_, |
| 399 blocking_task_runner_)); | 409 blocking_task_runner_)); |
| 400 feed_loader_->AddObserver(this); | 410 feed_loader_->AddObserver(this); |
| 401 | 411 |
| 402 // Allocate the drive operation handlers. | 412 // Allocate the drive operation handlers. |
| 403 drive_operations_.Init(drive_service_, | 413 drive_operations_.Init(drive_service_, |
| 404 this, // DriveFileSystemInterface | 414 this, // DriveFileSystemInterface |
| (...skipping 2135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2540 return; | 2550 return; |
| 2541 } | 2551 } |
| 2542 | 2552 |
| 2543 PlatformFileInfoProto entry_file_info; | 2553 PlatformFileInfoProto entry_file_info; |
| 2544 DriveEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); | 2554 DriveEntry::ConvertPlatformFileInfoToProto(*file_info, &entry_file_info); |
| 2545 *entry_proto->mutable_file_info() = entry_file_info; | 2555 *entry_proto->mutable_file_info() = entry_file_info; |
| 2546 callback.Run(DRIVE_FILE_OK, entry_proto.Pass()); | 2556 callback.Run(DRIVE_FILE_OK, entry_proto.Pass()); |
| 2547 } | 2557 } |
| 2548 | 2558 |
| 2549 } // namespace drive | 2559 } // namespace drive |
| OLD | NEW |