Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4985)

Unified Diff: chrome/browser/chromeos/arc/fileapi/arc_file_system_instance_util.cc

Issue 2616223002: arc: Use ARC_GET_INSTANCE_FOR_METHOD for getting file_system instance (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/arc/fileapi/arc_file_system_instance_util.cc
diff --git a/chrome/browser/chromeos/arc/fileapi/arc_file_system_instance_util.cc b/chrome/browser/chromeos/arc/fileapi/arc_file_system_instance_util.cc
index dc1c9e31ddff74ccb5ada8970f882e0bc013b197..9466388ab514c39bde1b4a49355db765b56336e5 100644
--- a/chrome/browser/chromeos/arc/fileapi/arc_file_system_instance_util.cc
+++ b/chrome/browser/chromeos/arc/fileapi/arc_file_system_instance_util.cc
@@ -14,6 +14,14 @@
#include "content/public/browser/browser_thread.h"
#include "url/gurl.h"
+#define GET_FILE_SYSTEM_INSTANCE(method_name) \
+ (arc::ArcServiceManager::Get() \
+ ? ARC_GET_INSTANCE_FOR_METHOD(arc::ArcServiceManager::Get() \
+ ->arc_bridge_service() \
+ ->file_system(), \
+ method_name) \
+ : nullptr)
+
using content::BrowserThread;
namespace arc {
@@ -22,28 +30,6 @@ namespace file_system_instance_util {
namespace {
-constexpr uint32_t kGetFileSizeVersion = 1;
-constexpr uint32_t kOpenFileToReadVersion = 1;
-constexpr uint32_t kGetDocumentVersion = 2;
-constexpr uint32_t kGetChildDocumentsVersion = 2;
-
-// Returns FileSystemInstance for the given |min_version|, if found.
-// Otherwise, nullptr.
-mojom::FileSystemInstance* GetFileSystemInstance(
- const std::string& method_name_for_logging,
- uint32_t min_version) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- auto* arc_service_manager = arc::ArcServiceManager::Get();
- if (!arc_service_manager) {
- LOG(ERROR) << "Failed to get ArcServiceManager.";
- return nullptr;
- }
- // TODO(lhchavez): Stop calling GetInstanceForVersion() directly.
- return arc_service_manager->arc_bridge_service()
- ->file_system()
- ->GetInstanceForVersion(min_version, method_name_for_logging.c_str());
-}
-
template <typename T>
void PostToIOThread(const base::Callback<void(T)>& callback, T result) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
@@ -55,8 +41,7 @@ void PostToIOThread(const base::Callback<void(T)>& callback, T result) {
void GetFileSizeOnUIThread(const GURL& arc_url,
const GetFileSizeCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- auto* file_system_instance =
- GetFileSystemInstance("GetFileSize", kGetFileSizeVersion);
+ auto* file_system_instance = GET_FILE_SYSTEM_INSTANCE(GetFileSize);
if (!file_system_instance) {
callback.Run(-1);
return;
@@ -67,8 +52,7 @@ void GetFileSizeOnUIThread(const GURL& arc_url,
void OpenFileToReadOnUIThread(const GURL& arc_url,
const OpenFileToReadCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- auto* file_system_instance =
- GetFileSystemInstance("OpenFileToRead", kOpenFileToReadVersion);
+ auto* file_system_instance = GET_FILE_SYSTEM_INSTANCE(OpenFileToRead);
if (!file_system_instance) {
callback.Run(mojo::ScopedHandle());
return;
@@ -80,8 +64,7 @@ void GetDocumentOnUIThread(const std::string& authority,
const std::string& document_id,
const GetDocumentCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- auto* file_system_instance =
- GetFileSystemInstance("GetDocument", kGetDocumentVersion);
+ auto* file_system_instance = GET_FILE_SYSTEM_INSTANCE(GetDocument);
if (!file_system_instance) {
callback.Run(mojom::DocumentPtr());
return;
@@ -93,8 +76,7 @@ void GetChildDocumentsOnUIThread(const std::string& authority,
const std::string& parent_document_id,
const GetChildDocumentsCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- auto* file_system_instance =
- GetFileSystemInstance("GetChildDocuments", kGetChildDocumentsVersion);
+ auto* file_system_instance = GET_FILE_SYSTEM_INSTANCE(GetChildDocuments);
if (!file_system_instance) {
callback.Run(base::nullopt);
return;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698