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

Unified Diff: chrome/browser/media_galleries/fileapi/safe_audio_video_checker.cc

Issue 2639503002: Convert utility process CheckMediaFile IPC to mojo (Closed)
Patch Set: Removed unused #include files, add TODO. 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
Index: chrome/browser/media_galleries/fileapi/safe_audio_video_checker.cc
diff --git a/chrome/browser/media_galleries/fileapi/safe_audio_video_checker.cc b/chrome/browser/media_galleries/fileapi/safe_audio_video_checker.cc
index 85dcf4fb480c08009ff22fd535b63b64ddc20657..f13242b160a4d275ec34c42d56f18135c56279cc 100644
--- a/chrome/browser/media_galleries/fileapi/safe_audio_video_checker.cc
+++ b/chrome/browser/media_galleries/fileapi/safe_audio_video_checker.cc
@@ -4,26 +4,20 @@
#include "chrome/browser/media_galleries/fileapi/safe_audio_video_checker.h"
-#include <stdint.h>
#include <utility>
#include "base/bind.h"
#include "base/callback.h"
-#include "base/location.h"
#include "base/logging.h"
-#include "base/process/process_handle.h"
-#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
-#include "chrome/common/chrome_utility_messages.h"
-#include "chrome/common/extensions/chrome_utility_extensions_messages.h"
+#include "base/time/time.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/child_process_data.h"
#include "content/public/browser/utility_process_host.h"
-#include "ipc/ipc_message_macros.h"
-#include "ipc/ipc_platform_file.h"
+#include "services/service_manager/public/cpp/interface_provider.h"
#include "ui/base/l10n/l10n_util.h"
+// TODO(noel): remove state_ once this code is all mojo.
SafeAudioVideoChecker::SafeAudioVideoChecker(
base::File file,
const storage::CopyOrMoveFileValidator::ResultCallback& callback)
@@ -43,21 +37,22 @@ void SafeAudioVideoChecker::Start() {
return;
}
- IPC::PlatformFileForTransit file_for_transit =
- IPC::TakePlatformFileForTransit(std::move(file_));
- if (file_for_transit == IPC::InvalidPlatformFileForTransit()) {
- OnCheckingFinished(false /* valid? */);
- return;
- }
-
utility_process_host_ = content::UtilityProcessHost::Create(
this, base::ThreadTaskRunnerHandle::Get())->AsWeakPtr();
utility_process_host_->SetName(l10n_util::GetStringUTF16(
IDS_UTILITY_PROCESS_MEDIA_FILE_CHECKER_NAME));
- const int64_t kFileDecodeTimeInMS = 250;
- utility_process_host_->Send(new ChromeUtilityMsg_CheckMediaFile(
- kFileDecodeTimeInMS, file_for_transit));
+ utility_process_host_->Start();
+
+ utility_process_host_->GetRemoteInterfaces()->GetInterface(&interface_);
+ interface_.set_connection_error_handler(
+ base::Bind(&SafeAudioVideoChecker::OnCheckingFinished, this, false));
+
+ constexpr base::TimeDelta kFileDecodeTime =
+ base::TimeDelta::FromMilliseconds(250);
+ interface_->CheckMediaFile(
+ kFileDecodeTime, std::move(file_),
+ base::Bind(&SafeAudioVideoChecker::OnCheckingFinished, this));
}
SafeAudioVideoChecker::~SafeAudioVideoChecker() {}
@@ -68,20 +63,17 @@ void SafeAudioVideoChecker::OnCheckingFinished(bool valid) {
return;
state_ = FINISHED_STATE;
+ interface_.reset();
callback_.Run(valid ? base::File::FILE_OK :
base::File::FILE_ERROR_SECURITY);
}
+// TODO(noel): remove, use the utility process mojo host client.
void SafeAudioVideoChecker::OnProcessCrashed(int exit_code) {
OnCheckingFinished(false);
}
+// TODO(noel): remove, use the utility process mojo host client.
bool SafeAudioVideoChecker::OnMessageReceived(const IPC::Message& message) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(SafeAudioVideoChecker, message)
- IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_CheckMediaFile_Finished,
- OnCheckingFinished)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
+ return false;
}

Powered by Google App Engine
This is Rietveld 408576698