Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / content / browser / renderer_host / pepper / pepper_internal_file_ref_backend.cc
index 4aba18b..ddab7c0 100644 (file)
@@ -7,7 +7,7 @@
 #include <string>
 
 #include "base/callback.h"
-#include "base/file_util.h"
+#include "base/files/file_util.h"
 #include "base/files/file_util_proxy.h"
 #include "content/browser/child_process_security_policy_impl.h"
 #include "content/browser/fileapi/browser_file_system_helper.h"
 #include "ppapi/thunk/enter.h"
 #include "ppapi/thunk/ppb_file_ref_api.h"
 #include "ppapi/thunk/ppb_file_system_api.h"
-#include "webkit/browser/fileapi/file_system_operation.h"
-#include "webkit/browser/fileapi/file_system_operation_runner.h"
-#include "webkit/browser/fileapi/file_system_url.h"
-#include "webkit/common/fileapi/file_system_util.h"
+#include "storage/browser/fileapi/file_system_operation.h"
+#include "storage/browser/fileapi/file_system_operation_runner.h"
+#include "storage/browser/fileapi/file_system_url.h"
+#include "storage/common/fileapi/file_system_util.h"
 
 using ppapi::host::PpapiHost;
 using ppapi::host::ResourceHost;
@@ -47,23 +47,23 @@ PepperInternalFileRefBackend::PepperInternalFileRefBackend(
     PpapiHost* host,
     int render_process_id,
     base::WeakPtr<PepperFileSystemBrowserHost> fs_host,
-    const std::string& path) : host_(host),
-                               render_process_id_(render_process_id),
-                               fs_host_(fs_host),
-                               fs_type_(fs_host->GetType()),
-                               path_(path),
-                               weak_factory_(this) {
+    const std::string& path)
+    : host_(host),
+      render_process_id_(render_process_id),
+      fs_host_(fs_host),
+      fs_type_(fs_host->GetType()),
+      path_(path),
+      weak_factory_(this) {
   ppapi::NormalizeInternalPath(&path_);
 }
 
-PepperInternalFileRefBackend::~PepperInternalFileRefBackend() {
-}
+PepperInternalFileRefBackend::~PepperInternalFileRefBackend() {}
 
-fileapi::FileSystemURL PepperInternalFileRefBackend::GetFileSystemURL() const {
+storage::FileSystemURL PepperInternalFileRefBackend::GetFileSystemURL() const {
   if (!fs_url_.is_valid() && fs_host_.get() && fs_host_->IsOpened()) {
-    GURL fs_path = fs_host_->GetRootUrl().Resolve(
-        net::EscapePath(path_.substr(1)));
-    scoped_refptr<fileapi::FileSystemContext> fs_context =
+    GURL fs_path =
+        fs_host_->GetRootUrl().Resolve(net::EscapePath(path_.substr(1)));
+    scoped_refptr<storage::FileSystemContext> fs_context =
         GetFileSystemContext();
     if (fs_context.get())
       fs_url_ = fs_context->CrackURL(fs_path);
@@ -75,7 +75,7 @@ base::FilePath PepperInternalFileRefBackend::GetExternalFilePath() const {
   return base::FilePath();
 }
 
-scoped_refptr<fileapi::FileSystemContext>
+scoped_refptr<storage::FileSystemContext>
 PepperInternalFileRefBackend::GetFileSystemContext() const {
   if (!fs_host_.get())
     return NULL;
@@ -146,7 +146,7 @@ int32_t PepperInternalFileRefBackend::Rename(
   if (!GetFileSystemURL().is_valid())
     return PP_ERROR_FAILED;
 
-  fileapi::FileSystemURL new_url = new_file_ref->GetFileSystemURL();
+  storage::FileSystemURL new_url = new_file_ref->GetFileSystemURL();
   if (!new_url.is_valid())
     return PP_ERROR_FAILED;
   if (!new_url.IsInSameFileSystem(GetFileSystemURL()))
@@ -155,7 +155,7 @@ int32_t PepperInternalFileRefBackend::Rename(
   GetFileSystemContext()->operation_runner()->Move(
       GetFileSystemURL(),
       new_url,
-      fileapi::FileSystemOperation::OPTION_NONE,
+      storage::FileSystemOperation::OPTION_NONE,
       base::Bind(&PepperInternalFileRefBackend::DidFinish,
                  weak_factory_.GetWeakPtr(),
                  reply_context,
@@ -197,8 +197,8 @@ int32_t PepperInternalFileRefBackend::ReadDirectoryEntries(
   if (!GetFileSystemURL().is_valid())
     return PP_ERROR_FAILED;
 
-  fileapi::FileSystemOperation::FileEntryList* accumulated_file_list
-      = new fileapi::FileSystemOperation::FileEntryList;
+  storage::FileSystemOperation::FileEntryList* accumulated_file_list =
+      new storage::FileSystemOperation::FileEntryList;
   GetFileSystemContext()->operation_runner()->ReadDirectory(
       GetFileSystemURL(),
       base::Bind(&PepperInternalFileRefBackend::ReadDirectoryComplete,
@@ -210,12 +210,12 @@ int32_t PepperInternalFileRefBackend::ReadDirectoryEntries(
 
 void PepperInternalFileRefBackend::ReadDirectoryComplete(
     ppapi::host::ReplyMessageContext context,
-    fileapi::FileSystemOperation::FileEntryList* accumulated_file_list,
+    storage::FileSystemOperation::FileEntryList* accumulated_file_list,
     base::File::Error error,
-    const fileapi::FileSystemOperation::FileEntryList& file_list,
+    const storage::FileSystemOperation::FileEntryList& file_list,
     bool has_more) {
-  accumulated_file_list->insert(accumulated_file_list->end(),
-                                file_list.begin(), file_list.end());
+  accumulated_file_list->insert(
+      accumulated_file_list->end(), file_list.begin(), file_list.end());
   if (has_more)
     return;
 
@@ -228,9 +228,10 @@ void PepperInternalFileRefBackend::ReadDirectoryComplete(
     if (dir_path.empty() || dir_path[dir_path.size() - 1] != '/')
       dir_path += '/';
 
-    for (fileapi::FileSystemOperation::FileEntryList::const_iterator it =
+    for (storage::FileSystemOperation::FileEntryList::const_iterator it =
              accumulated_file_list->begin();
-         it != accumulated_file_list->end(); ++it) {
+         it != accumulated_file_list->end();
+         ++it) {
       if (it->is_directory)
         file_types.push_back(PP_FILETYPE_DIRECTORY);
       else
@@ -240,59 +241,60 @@ void PepperInternalFileRefBackend::ReadDirectoryComplete(
       info.file_system_type = fs_type_;
       info.file_system_plugin_resource = fs_host_->pp_resource();
       std::string path =
-          dir_path + fileapi::FilePathToString(base::FilePath(it->name));
+          dir_path + storage::FilePathToString(base::FilePath(it->name));
       info.internal_path = path;
       info.display_name = ppapi::GetNameForInternalFilePath(path);
       infos.push_back(info);
     }
   }
 
-  host_->SendReply(context,
+  host_->SendReply(
+      context,
       PpapiPluginMsg_FileRef_ReadDirectoryEntriesReply(infos, file_types));
 }
 
 int32_t PepperInternalFileRefBackend::GetAbsolutePath(
     ppapi::host::ReplyMessageContext reply_context) {
   host_->SendReply(reply_context,
-      PpapiPluginMsg_FileRef_GetAbsolutePathReply(path_));
+                   PpapiPluginMsg_FileRef_GetAbsolutePathReply(path_));
   return PP_OK_COMPLETIONPENDING;
 }
 
 int32_t PepperInternalFileRefBackend::CanRead() const {
-  fileapi::FileSystemURL url = GetFileSystemURL();
+  storage::FileSystemURL url = GetFileSystemURL();
   if (!FileSystemURLIsValid(GetFileSystemContext().get(), url))
     return PP_ERROR_FAILED;
-  if (!ChildProcessSecurityPolicyImpl::GetInstance()->
-          CanReadFileSystemFile(render_process_id_, url)) {
+  if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFileSystemFile(
+          render_process_id_, url)) {
     return PP_ERROR_NOACCESS;
   }
   return PP_OK;
 }
 
 int32_t PepperInternalFileRefBackend::CanWrite() const {
-  fileapi::FileSystemURL url = GetFileSystemURL();
+  storage::FileSystemURL url = GetFileSystemURL();
   if (!FileSystemURLIsValid(GetFileSystemContext().get(), url))
     return PP_ERROR_FAILED;
-  if (!ChildProcessSecurityPolicyImpl::GetInstance()->
-          CanWriteFileSystemFile(render_process_id_, url)) {
+  if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanWriteFileSystemFile(
+          render_process_id_, url)) {
     return PP_ERROR_NOACCESS;
   }
   return PP_OK;
 }
 
 int32_t PepperInternalFileRefBackend::CanCreate() const {
-  fileapi::FileSystemURL url = GetFileSystemURL();
+  storage::FileSystemURL url = GetFileSystemURL();
   if (!FileSystemURLIsValid(GetFileSystemContext().get(), url))
     return PP_ERROR_FAILED;
-  if (!ChildProcessSecurityPolicyImpl::GetInstance()->
-          CanCreateFileSystemFile(render_process_id_, url)) {
+  if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanCreateFileSystemFile(
+          render_process_id_, url)) {
     return PP_ERROR_NOACCESS;
   }
   return PP_OK;
 }
 
 int32_t PepperInternalFileRefBackend::CanReadWrite() const {
-  fileapi::FileSystemURL url = GetFileSystemURL();
+  storage::FileSystemURL url = GetFileSystemURL();
   if (!FileSystemURLIsValid(GetFileSystemContext().get(), url))
     return PP_ERROR_FAILED;
   ChildProcessSecurityPolicyImpl* policy =