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_util.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/file_path.h" | 15 #include "base/file_path.h" |
16 #include "base/file_util.h" | 16 #include "base/file_util.h" |
17 #include "base/json/json_reader.h" | 17 #include "base/json/json_reader.h" |
18 #include "base/logging.h" | 18 #include "base/logging.h" |
19 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
21 #include "base/stringprintf.h" | 21 #include "base/stringprintf.h" |
22 #include "base/threading/sequenced_worker_pool.h" | 22 #include "base/threading/sequenced_worker_pool.h" |
23 #include "base/time.h" | 23 #include "base/time.h" |
24 #include "base/tracked_objects.h" | 24 #include "base/tracked_objects.h" |
25 #include "chrome/browser/chromeos/gdata/drive.pb.h" | 25 #include "chrome/browser/chromeos/gdata/drive.pb.h" |
26 #include "chrome/browser/chromeos/gdata/drive_file_system_interface.h" | 26 #include "chrome/browser/chromeos/gdata/drive_file_system_interface.h" |
| 27 #include "chrome/browser/chromeos/gdata/drive_system_service.h" |
27 #include "chrome/browser/chromeos/gdata/file_write_helper.h" | 28 #include "chrome/browser/chromeos/gdata/file_write_helper.h" |
28 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" | |
29 #include "chrome/browser/chromeos/login/user.h" | 29 #include "chrome/browser/chromeos/login/user.h" |
30 #include "chrome/browser/chromeos/login/user_manager.h" | 30 #include "chrome/browser/chromeos/login/user_manager.h" |
31 #include "chrome/browser/prefs/pref_service.h" | 31 #include "chrome/browser/prefs/pref_service.h" |
32 #include "chrome/browser/profiles/profile.h" | 32 #include "chrome/browser/profiles/profile.h" |
33 #include "chrome/browser/ui/browser.h" | 33 #include "chrome/browser/ui/browser.h" |
34 #include "chrome/browser/ui/browser_finder.h" | 34 #include "chrome/browser/ui/browser_finder.h" |
35 #include "chrome/common/chrome_switches.h" | 35 #include "chrome/common/chrome_switches.h" |
36 #include "chrome/common/chrome_version_info.h" | 36 #include "chrome/common/chrome_version_info.h" |
37 #include "chrome/common/pref_names.h" | 37 #include "chrome/common/pref_names.h" |
38 #include "chrome/common/url_constants.h" | 38 #include "chrome/common/url_constants.h" |
(...skipping 16 matching lines...) Expand all Loading... |
55 const FilePath::CharType* kGDataMountPointPathComponents[] = { | 55 const FilePath::CharType* kGDataMountPointPathComponents[] = { |
56 "/", "special", "drive" | 56 "/", "special", "drive" |
57 }; | 57 }; |
58 | 58 |
59 const int kReadOnlyFilePermissions = base::PLATFORM_FILE_OPEN | | 59 const int kReadOnlyFilePermissions = base::PLATFORM_FILE_OPEN | |
60 base::PLATFORM_FILE_READ | | 60 base::PLATFORM_FILE_READ | |
61 base::PLATFORM_FILE_EXCLUSIVE_READ | | 61 base::PLATFORM_FILE_EXCLUSIVE_READ | |
62 base::PLATFORM_FILE_ASYNC; | 62 base::PLATFORM_FILE_ASYNC; |
63 | 63 |
64 DriveFileSystemInterface* GetDriveFileSystem(Profile* profile) { | 64 DriveFileSystemInterface* GetDriveFileSystem(Profile* profile) { |
65 GDataSystemService* system_service = | 65 DriveSystemService* system_service = |
66 GDataSystemServiceFactory::GetForProfile(profile); | 66 DriveSystemServiceFactory::GetForProfile(profile); |
67 return system_service ? system_service->file_system() : NULL; | 67 return system_service ? system_service->file_system() : NULL; |
68 } | 68 } |
69 | 69 |
70 DriveCache* GetDriveCache(Profile* profile) { | 70 DriveCache* GetDriveCache(Profile* profile) { |
71 GDataSystemService* system_service = | 71 DriveSystemService* system_service = |
72 GDataSystemServiceFactory::GetForProfile(profile); | 72 DriveSystemServiceFactory::GetForProfile(profile); |
73 return system_service ? system_service->cache() : NULL; | 73 return system_service ? system_service->cache() : NULL; |
74 } | 74 } |
75 | 75 |
76 FileWriteHelper* GetFileWriteHelper(Profile* profile) { | 76 FileWriteHelper* GetFileWriteHelper(Profile* profile) { |
77 GDataSystemService* system_service = | 77 DriveSystemService* system_service = |
78 GDataSystemServiceFactory::GetForProfile(profile); | 78 DriveSystemServiceFactory::GetForProfile(profile); |
79 return system_service ? system_service->file_write_helper() : NULL; | 79 return system_service ? system_service->file_write_helper() : NULL; |
80 } | 80 } |
81 | 81 |
82 void GetHostedDocumentURLBlockingThread(const FilePath& drive_cache_path, | 82 void GetHostedDocumentURLBlockingThread(const FilePath& drive_cache_path, |
83 GURL* url) { | 83 GURL* url) { |
84 std::string json; | 84 std::string json; |
85 if (!file_util::ReadFileToString(drive_cache_path, &json)) { | 85 if (!file_util::ReadFileToString(drive_cache_path, &json)) { |
86 NOTREACHED() << "Unable to read file " << drive_cache_path.value(); | 86 NOTREACHED() << "Unable to read file " << drive_cache_path.value(); |
87 return; | 87 return; |
88 } | 88 } |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 const base::Closure& reply_task) { | 652 const base::Closure& reply_task) { |
653 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 653 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
654 | 654 |
655 const bool posted = blocking_task_runner->PostTaskAndReply( | 655 const bool posted = blocking_task_runner->PostTaskAndReply( |
656 from_here, request_task, reply_task); | 656 from_here, request_task, reply_task); |
657 DCHECK(posted); | 657 DCHECK(posted); |
658 } | 658 } |
659 | 659 |
660 } // namespace util | 660 } // namespace util |
661 } // namespace gdata | 661 } // namespace gdata |
OLD | NEW |