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

Unified Diff: content/renderer/manifest/manifest_manager.cc

Issue 1913043002: Convert ManifestManager IPCs to Mojo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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: content/renderer/manifest/manifest_manager.cc
diff --git a/content/renderer/manifest/manifest_manager.cc b/content/renderer/manifest/manifest_manager.cc
index 69a75de2500139e741363a379aade14db2d57ef2..bc6c015bb8aa5649a32c123bbb8369dbcc24586f 100644
--- a/content/renderer/manifest/manifest_manager.cc
+++ b/content/renderer/manifest/manifest_manager.cc
@@ -6,7 +6,6 @@
#include "base/bind.h"
#include "base/strings/nullable_string16.h"
-#include "content/common/manifest_manager_messages.h"
#include "content/public/renderer/render_frame.h"
#include "content/renderer/fetchers/manifest_fetcher.h"
#include "content/renderer/manifest/manifest_parser.h"
@@ -34,61 +33,22 @@ ManifestManager::~ManifestManager() {
ResolveCallbacks(ResolveStateFailure);
}
-bool ManifestManager::OnMessageReceived(const IPC::Message& message) {
- bool handled = true;
-
- IPC_BEGIN_MESSAGE_MAP(ManifestManager, message)
- IPC_MESSAGE_HANDLER(ManifestManagerMsg_HasManifest, OnHasManifest)
- IPC_MESSAGE_HANDLER(ManifestManagerMsg_RequestManifest, OnRequestManifest)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
-
- return handled;
-}
-
-void ManifestManager::OnHasManifest(int request_id) {
+void ManifestManager::HasManifest(const HasManifestCallback& callback) {
GURL url(render_frame()->GetWebFrame()->document().manifestURL());
- bool has_manifest = may_have_manifest_ && !url.is_empty();
- Send(new ManifestManagerHostMsg_HasManifestResponse(
- routing_id(), request_id, has_manifest));
+ callback.Run(may_have_manifest_ && !url.is_empty());
}
-void ManifestManager::OnRequestManifest(int request_id) {
+void ManifestManager::RequestManifest(const RequestManifestCallback& callback) {
GetManifest(base::Bind(&ManifestManager::OnRequestManifestComplete,
- base::Unretained(this), request_id));
+ base::Unretained(this), callback));
}
void ManifestManager::OnRequestManifestComplete(
- int request_id, const Manifest& manifest,
+ const RequestManifestCallback& callback,
+ const Manifest& manifest,
const ManifestDebugInfo&) {
- // When sent via IPC, the Manifest must follow certain security rules.
- Manifest ipc_manifest = manifest;
- ipc_manifest.name = base::NullableString16(
- ipc_manifest.name.string().substr(0, Manifest::kMaxIPCStringLength),
- ipc_manifest.name.is_null());
- ipc_manifest.short_name = base::NullableString16(
- ipc_manifest.short_name.string().substr(0,
- Manifest::kMaxIPCStringLength),
- ipc_manifest.short_name.is_null());
- for (auto& icon : ipc_manifest.icons) {
- icon.type = base::NullableString16(
- icon.type.string().substr(0, Manifest::kMaxIPCStringLength),
- icon.type.is_null());
- }
- ipc_manifest.gcm_sender_id = base::NullableString16(
- ipc_manifest.gcm_sender_id.string().substr(
- 0, Manifest::kMaxIPCStringLength),
- ipc_manifest.gcm_sender_id.is_null());
- for (auto& related_application : ipc_manifest.related_applications) {
- related_application.id =
- base::NullableString16(related_application.id.string().substr(
- 0, Manifest::kMaxIPCStringLength),
- related_application.id.is_null());
- }
-
- Send(new ManifestManagerHostMsg_RequestManifestResponse(
- routing_id(), request_id, ipc_manifest));
+ callback.Run(manifest);
}
void ManifestManager::GetManifest(const GetManifestCallback& callback) {
@@ -197,17 +157,21 @@ void ManifestManager::ResolveCallbacks(ResolveState state) {
manifest_dirty_ = state != ResolveStateSuccess;
- std::list<GetManifestCallback> callbacks;
- callbacks.swap(pending_callbacks_);
+ Manifest manifest = manifest_;
+ std::vector<GetManifestCallback> callbacks = std::move(pending_callbacks_);
+ pending_callbacks_.clear();
- for (std::list<GetManifestCallback>::const_iterator it = callbacks.begin();
- it != callbacks.end(); ++it) {
- it->Run(manifest_, manifest_debug_info_);
- }
+ for (const auto& callback : callbacks)
+ callback.Run(manifest, manifest_debug_info_);
+}
+
+void ManifestManager::BindToRequest(
+ blink::mojom::ManifestManagerRequest request) {
+ bindings_.AddBinding(this, std::move(request));
}
void ManifestManager::OnDestruct() {
delete this;
}
-} // namespace content
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698