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

Unified Diff: chrome/browser/chromeos/drive/fileapi/file_system_backend_delegate.cc

Issue 527773003: Add GetURLForBrowserTab method to the external file system backend. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove GURL header. Created 6 years, 3 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
Index: chrome/browser/chromeos/drive/fileapi/file_system_backend_delegate.cc
diff --git a/chrome/browser/chromeos/drive/fileapi/file_system_backend_delegate.cc b/chrome/browser/chromeos/drive/fileapi/file_system_backend_delegate.cc
index a191e75f4e9f3b19e12e49205a8734264116145e..b1aa8ecf8820778f1eb333953c8bc3e0d85c0871 100644
--- a/chrome/browser/chromeos/drive/fileapi/file_system_backend_delegate.cc
+++ b/chrome/browser/chromeos/drive/fileapi/file_system_backend_delegate.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/chromeos/drive/file_system_interface.h"
#include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/chromeos/drive/fileapi/async_file_util.h"
#include "chrome/browser/chromeos/drive/fileapi/fileapi_worker.h"
@@ -22,6 +23,46 @@
using content::BrowserThread;
namespace drive {
+namespace {
+void PostURLOnIOThread(
+ base::Callback<void(const GURL& url)> callback,
+ const GURL& url) {
+ BrowserThread::PostTask(
+ BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(callback, url));
+}
+
+void GetAlternativeURLOnUIThreadWithResourceEntry(
+ base::Callback<void(const GURL& url)> callback,
+ FileError error,
+ scoped_ptr<ResourceEntry> entry) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ GURL url;
+ if (error == FILE_ERROR_OK &&
+ entry->has_file_specific_info() &&
+ entry->file_specific_info().is_hosted_document()) {
+ url = GURL(entry->file_specific_info().alternate_url());
+ }
+ PostURLOnIOThread(callback, url);
+}
+
+void GetAlternativeURLOnUIThread(
+ const storage::FileSystemURL& url,
+ base::Callback<void(const GURL& url)> callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ FileSystemInterface* const file_system =
+ fileapi_internal::GetFileSystemFromUrl(url);
+ if (!file_system) {
+ PostURLOnIOThread(callback, GURL());
+ return;
+ }
+ const base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
+ file_system->GetResourceEntry(
+ file_path,
+ base::Bind(GetAlternativeURLOnUIThreadWithResourceEntry, callback));
+}
+} // namespace
FileSystemBackendDelegate::FileSystemBackendDelegate()
: async_file_util_(new internal::AsyncFileUtil) {
@@ -86,4 +127,14 @@ storage::WatcherManager* FileSystemBackendDelegate::GetWatcherManager(
return NULL;
}
+void FileSystemBackendDelegate::GetAlternativeURL(
+ const storage::FileSystemURL& url,
+ base::Callback<void(const GURL& url)> callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(GetAlternativeURLOnUIThread, url, callback));
+}
+
} // namespace drive

Powered by Google App Engine
This is Rietveld 408576698