Commit 09f491e1 authored by Hassan Talat's avatar Hassan Talat Committed by Chromium LUCI CQ

WebShare: Pull out PrepareDirectoryTask & StoreFile(s)Task

This CL pulls out the tasks from the chromeos folder and moves it to the
webshare root folder so the macOS implementation can use it.

Bug: 1144920
Change-Id: I942399d1da8759bcbd77e46a3fde0b400e96789c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2615664
Commit-Queue: Eric Willigers <ericwilligers@chromium.org>
Reviewed-by: default avatarEric Willigers <ericwilligers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841319}
parent a9e6e0ca
...@@ -4511,7 +4511,7 @@ static_library("browser") { ...@@ -4511,7 +4511,7 @@ static_library("browser") {
"//chrome/browser/nearby_sharing/scheduling", "//chrome/browser/nearby_sharing/scheduling",
"//chrome/browser/ui/webui/nearby_share:mojom", "//chrome/browser/ui/webui/nearby_share:mojom",
"//chrome/browser/ui/webui/nearby_share/public/mojom", "//chrome/browser/ui/webui/nearby_share/public/mojom",
"//chrome/browser/webshare/chromeos:storage", "//chrome/browser/webshare:storage",
"//chromeos/components/account_manager", "//chromeos/components/account_manager",
"//chromeos/components/cdm_factory_daemon:cdm_factory_daemon_browser", "//chromeos/components/cdm_factory_daemon:cdm_factory_daemon_browser",
"//chromeos/components/quick_answers", "//chromeos/components/quick_answers",
......
...@@ -4,10 +4,36 @@ ...@@ -4,10 +4,36 @@
import("//build/config/chromeos/ui_mode.gni") import("//build/config/chromeos/ui_mode.gni")
static_library("storage") {
if (is_chromeos || is_mac) {
sources = [
"prepare_directory_task.cc",
"prepare_directory_task.h",
"store_file_task.cc",
"store_file_task.h",
"store_files_task.cc",
"store_files_task.h",
]
deps = [
"//content/public/browser",
"//mojo/public/cpp/bindings",
]
public_deps = [
"//base",
"//third_party/blink/public/common",
]
}
}
source_set("unit_tests") { source_set("unit_tests") {
testonly = true testonly = true
sources = [ "share_service_unittest.cc" ] sources = [ "share_service_unittest.cc" ]
if (is_chromeos || is_mac) {
sources += [ "prepare_directory_task_unittest.cc" ]
}
deps = [ deps = [
"//base/test:test_support", "//base/test:test_support",
"//build:chromeos_buildflags", "//build:chromeos_buildflags",
...@@ -23,4 +49,8 @@ source_set("unit_tests") { ...@@ -23,4 +49,8 @@ source_set("unit_tests") {
if (is_chromeos_ash) { if (is_chromeos_ash) {
deps += [ "//chrome/browser/webshare/chromeos:unit_tests" ] deps += [ "//chrome/browser/webshare/chromeos:unit_tests" ]
} }
if (is_chromeos || is_mac) {
deps += [ "//chrome/browser/webshare:storage" ]
}
} }
...@@ -2,39 +2,17 @@ ...@@ -2,39 +2,17 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
static_library("storage") {
sources = [
"prepare_directory_task.cc",
"prepare_directory_task.h",
"store_file_task.cc",
"store_file_task.h",
"store_files_task.cc",
"store_files_task.h",
]
deps = [
"//content/public/browser",
"//mojo/public/cpp/bindings",
]
public_deps = [
"//base",
"//third_party/blink/public/common",
]
}
source_set("unit_tests") { source_set("unit_tests") {
testonly = true testonly = true
sources = [ sources = [ "sharesheet_client_unittest.cc" ]
"prepare_directory_task_unittest.cc",
"sharesheet_client_unittest.cc",
]
deps = [ deps = [
":storage",
"//base/test:test_support", "//base/test:test_support",
"//build:chromeos_buildflags", "//build:chromeos_buildflags",
"//chrome/browser", "//chrome/browser",
"//chrome/browser/chromeos:chromeos", "//chrome/browser/chromeos:chromeos",
"//chrome/browser/webshare:storage",
"//chrome/common", "//chrome/common",
"//chrome/test:test_support", "//chrome/test:test_support",
"//content/public/browser", "//content/public/browser",
......
...@@ -20,9 +20,9 @@ ...@@ -20,9 +20,9 @@
#include "chrome/browser/sharesheet/sharesheet_service.h" #include "chrome/browser/sharesheet/sharesheet_service.h"
#include "chrome/browser/sharesheet/sharesheet_service_factory.h" #include "chrome/browser/sharesheet/sharesheet_service_factory.h"
#include "chrome/browser/visibility_timer_tab_helper.h" #include "chrome/browser/visibility_timer_tab_helper.h"
#include "chrome/browser/webshare/chromeos/prepare_directory_task.h" #include "chrome/browser/webshare/prepare_directory_task.h"
#include "chrome/browser/webshare/chromeos/store_files_task.h"
#include "chrome/browser/webshare/share_service_impl.h" #include "chrome/browser/webshare/share_service_impl.h"
#include "chrome/browser/webshare/store_files_task.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
#include "components/services/app_service/public/cpp/intent_util.h" #include "components/services/app_service/public/cpp/intent_util.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
#include "chrome/browser/chromeos/file_manager/path_util.h" #include "chrome/browser/chromeos/file_manager/path_util.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sharesheet/sharesheet_types.h" #include "chrome/browser/sharesheet/sharesheet_types.h"
#include "chrome/browser/webshare/chromeos/prepare_directory_task.h" #include "chrome/browser/webshare/prepare_directory_task.h"
#include "chrome/browser/webshare/chromeos/store_file_task.h" #include "chrome/browser/webshare/store_file_task.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "content/public/browser/site_instance.h" #include "content/public/browser/site_instance.h"
#include "content/public/test/web_contents_tester.h" #include "content/public/test/web_contents_tester.h"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/webshare/chromeos/prepare_directory_task.h" #include "chrome/browser/webshare/prepare_directory_task.h"
#include "base/files/file.h" #include "base/files/file.h"
#include "base/files/file_enumerator.h" #include "base/files/file_enumerator.h"
...@@ -10,8 +10,12 @@ ...@@ -10,8 +10,12 @@
#include "base/task/task_traits.h" #include "base/task/task_traits.h"
#include "base/task/thread_pool.h" #include "base/task/thread_pool.h"
#include "base/threading/scoped_blocking_call.h" #include "base/threading/scoped_blocking_call.h"
#include "build/build_config.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#if defined(OS_CHROMEOS)
#include "third_party/cros_system_api/constants/cryptohome.h" #include "third_party/cros_system_api/constants/cryptohome.h"
#endif
using content::BrowserThread; using content::BrowserThread;
...@@ -80,12 +84,14 @@ base::File::Error PrepareDirectoryTask::PrepareDirectory( ...@@ -80,12 +84,14 @@ base::File::Error PrepareDirectoryTask::PrepareDirectory(
} }
} }
#if defined(OS_CHROMEOS)
if (base::SysInfo::AmountOfFreeDiskSpace(directory) < if (base::SysInfo::AmountOfFreeDiskSpace(directory) <
static_cast<int64_t>(cryptohome::kMinFreeSpaceInBytes + static_cast<int64_t>(cryptohome::kMinFreeSpaceInBytes +
required_space)) { required_space)) {
result = base::File::FILE_ERROR_NO_SPACE; result = base::File::FILE_ERROR_NO_SPACE;
VLOG(1) << "Insufficient space for sharing files"; VLOG(1) << "Insufficient space for sharing files";
} }
#endif
} else { } else {
DCHECK(result != base::File::FILE_OK); DCHECK(result != base::File::FILE_OK);
VLOG(1) << "Could not create directory for shared files"; VLOG(1) << "Could not create directory for shared files";
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_WEBSHARE_CHROMEOS_PREPARE_DIRECTORY_TASK_H_ #ifndef CHROME_BROWSER_WEBSHARE_PREPARE_DIRECTORY_TASK_H_
#define CHROME_BROWSER_WEBSHARE_CHROMEOS_PREPARE_DIRECTORY_TASK_H_ #define CHROME_BROWSER_WEBSHARE_PREPARE_DIRECTORY_TASK_H_
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
...@@ -51,4 +51,4 @@ class PrepareDirectoryTask { ...@@ -51,4 +51,4 @@ class PrepareDirectoryTask {
} // namespace webshare } // namespace webshare
#endif // CHROME_BROWSER_WEBSHARE_CHROMEOS_PREPARE_DIRECTORY_TASK_H_ #endif // CHROME_BROWSER_WEBSHARE_PREPARE_DIRECTORY_TASK_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/webshare/chromeos/prepare_directory_task.h" #include "chrome/browser/webshare/prepare_directory_task.h"
#include <string> #include <string>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/webshare/chromeos/store_file_task.h" #include "chrome/browser/webshare/store_file_task.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/threading/scoped_blocking_call.h" #include "base/threading/scoped_blocking_call.h"
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_WEBSHARE_CHROMEOS_STORE_FILE_TASK_H_ #ifndef CHROME_BROWSER_WEBSHARE_STORE_FILE_TASK_H_
#define CHROME_BROWSER_WEBSHARE_CHROMEOS_STORE_FILE_TASK_H_ #define CHROME_BROWSER_WEBSHARE_STORE_FILE_TASK_H_
#include "base/files/file.h" #include "base/files/file.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
...@@ -63,4 +63,4 @@ class StoreFileTask : public blink::mojom::BlobReaderClient { ...@@ -63,4 +63,4 @@ class StoreFileTask : public blink::mojom::BlobReaderClient {
} // namespace webshare } // namespace webshare
#endif // CHROME_BROWSER_WEBSHARE_CHROMEOS_STORE_FILE_TASK_H_ #endif // CHROME_BROWSER_WEBSHARE_STORE_FILE_TASK_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/webshare/chromeos/store_files_task.h" #include "chrome/browser/webshare/store_files_task.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/task/thread_pool.h" #include "base/task/thread_pool.h"
......
...@@ -2,15 +2,15 @@ ...@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_WEBSHARE_CHROMEOS_STORE_FILES_TASK_H_ #ifndef CHROME_BROWSER_WEBSHARE_STORE_FILES_TASK_H_
#define CHROME_BROWSER_WEBSHARE_CHROMEOS_STORE_FILES_TASK_H_ #define CHROME_BROWSER_WEBSHARE_STORE_FILES_TASK_H_
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "chrome/browser/webshare/chromeos/store_file_task.h" #include "chrome/browser/webshare/store_file_task.h"
#include "third_party/blink/public/mojom/webshare/webshare.mojom.h" #include "third_party/blink/public/mojom/webshare/webshare.mojom.h"
namespace webshare { namespace webshare {
...@@ -45,4 +45,4 @@ class StoreFilesTask { ...@@ -45,4 +45,4 @@ class StoreFilesTask {
} // namespace webshare } // namespace webshare
#endif // CHROME_BROWSER_WEBSHARE_CHROMEOS_STORE_FILES_TASK_H_ #endif // CHROME_BROWSER_WEBSHARE_STORE_FILES_TASK_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment