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

Unified Diff: extensions/browser/extension_function_dispatcher.cc

Issue 2656013005: Better crash stacktraces for ExtensionFunction bad messages. (Closed)
Patch Set: sync 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
« no previous file with comments | « extensions/browser/extension_function.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/extension_function_dispatcher.cc
diff --git a/extensions/browser/extension_function_dispatcher.cc b/extensions/browser/extension_function_dispatcher.cc
index f63456c7fdb3aa3a2224e0295324168368418e8f..3d7dff5419f39461c2456c747402210963b7516a 100644
--- a/extensions/browser/extension_function_dispatcher.cc
+++ b/extensions/browser/extension_function_dispatcher.cc
@@ -26,12 +26,10 @@
#include "content/public/browser/render_process_host_observer.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/service_worker_context.h"
-#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/result_codes.h"
#include "extensions/browser/api_activity_monitor.h"
-#include "extensions/browser/bad_message.h"
#include "extensions/browser/extension_function_registry.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
@@ -80,40 +78,16 @@ struct Static {
};
base::LazyInstance<Static> g_global_io_data = LAZY_INSTANCE_INITIALIZER;
-void LogBadMessage(functions::HistogramValue histogram_value) {
- content::RecordAction(base::UserMetricsAction("BadMessageTerminate_EFD"));
- // Track the specific function's |histogram_value|, as this may indicate a
- // bug in that API's implementation.
- UMA_HISTOGRAM_ENUMERATION("Extensions.BadMessageFunctionName",
- histogram_value, functions::ENUM_BOUNDARY);
-}
-
-template <class T>
-void ReceivedBadMessage(T* bad_message_sender,
- bad_message::BadMessageReason reason,
- functions::HistogramValue histogram_value) {
- LogBadMessage(histogram_value);
- // The renderer has done validation before sending extension api requests.
- // Therefore, we should never receive a request that is invalid in a way
- // that JSON validation in the renderer should have caught. It could be an
- // attacker trying to exploit the browser, so we crash the renderer instead.
- bad_message::ReceivedBadMessage(bad_message_sender, reason);
-}
-
-template <class T>
void CommonResponseCallback(IPC::Sender* ipc_sender,
int routing_id,
- T* bad_message_sender,
int request_id,
ExtensionFunction::ResponseType type,
const base::ListValue& results,
- const std::string& error,
- functions::HistogramValue histogram_value) {
+ const std::string& error) {
DCHECK(ipc_sender);
if (type == ExtensionFunction::BAD_MESSAGE) {
- ReceivedBadMessage(bad_message_sender, bad_message::EFD_BAD_MESSAGE,
- histogram_value);
+ // The renderer will be shut down from ExtensionFunction::SetBadMessage().
return;
}
@@ -133,8 +107,8 @@ void IOThreadResponseCallback(
if (!ipc_sender.get())
return;
- CommonResponseCallback(ipc_sender.get(), routing_id, ipc_sender.get(),
- request_id, type, results, error, histogram_value);
+ CommonResponseCallback(ipc_sender.get(), routing_id, request_id, type,
+ results, error);
}
} // namespace
@@ -183,9 +157,8 @@ class ExtensionFunctionDispatcher::UIThreadResponseCallbackWrapper
const std::string& error,
functions::HistogramValue histogram_value) {
CommonResponseCallback(render_frame_host_,
- render_frame_host_->GetRoutingID(),
- render_frame_host_->GetProcess(), request_id, type,
- results, error, histogram_value);
+ render_frame_host_->GetRoutingID(), request_id, type,
+ results, error);
}
base::WeakPtr<ExtensionFunctionDispatcher> dispatcher_;
@@ -248,8 +221,7 @@ class ExtensionFunctionDispatcher::UIThreadWorkerResponseCallbackWrapper
content::RenderProcessHost* sender =
content::RenderProcessHost::FromID(render_process_id_);
if (type == ExtensionFunction::BAD_MESSAGE) {
- ReceivedBadMessage(sender, bad_message::EFD_BAD_MESSAGE_WORKER,
- histogram_value);
+ // The renderer will be shut down from ExtensionFunction::SetBadMessage().
return;
}
DCHECK(sender);
« no previous file with comments | « extensions/browser/extension_function.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698