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

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: . 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..e469fb0082bf253a07f52b926df32310d7cb89ec 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,42 @@
using content::BrowserThread;
namespace drive {
+namespace {
kinaba 2014/09/04 04:17:04 put a blank line between namespace { the following
hirono 2014/09/04 04:29:09 Done.
+void PostURLOnIOThread(const FileSystemBackendDelegate::URLCallback& callback,
kinaba 2014/09/04 04:17:04 Maybe: PostURLToIOThread? Or I think you can remo
hirono 2014/09/04 04:29:09 Removed the function.
+ const GURL& url) {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE, base::Bind(callback, url));
+}
+
+void GetURLForBrowserTabOnUIThreadWithResourceEntry(
+ const FileSystemBackendDelegate::URLCallback& 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 GetURLForBrowserTabOnUIThread(
+ const storage::FileSystemURL& url,
+ const FileSystemBackendDelegate::URLCallback& 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(GetURLForBrowserTabOnUIThreadWithResourceEntry, callback));
kinaba 2014/09/04 04:17:04 &GetURLFor...
hirono 2014/09/04 04:29:09 Done.
+}
+} // namespace
FileSystemBackendDelegate::FileSystemBackendDelegate()
: async_file_util_(new internal::AsyncFileUtil) {
@@ -86,4 +123,14 @@ storage::WatcherManager* FileSystemBackendDelegate::GetWatcherManager(
return NULL;
}
+void FileSystemBackendDelegate::GetURLForBrowserTab(
+ const storage::FileSystemURL& url,
+ const URLCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(GetURLForBrowserTabOnUIThread, url, callback));
kinaba 2014/09/04 04:17:04 &GetURLFor...
hirono 2014/09/04 04:29:09 Done.
+}
+
} // namespace drive

Powered by Google App Engine
This is Rietveld 408576698