Index: components/safe_json/testing_json_parser.cc |
diff --git a/components/safe_json/testing_json_parser.cc b/components/safe_json/testing_json_parser.cc |
index ea7e9c5469b45cc7378fa0cffe6df8ee75dce7ad..f7c81198d86971dcdfe93237a42b6ecd8d83baff 100644 |
--- a/components/safe_json/testing_json_parser.cc |
+++ b/components/safe_json/testing_json_parser.cc |
@@ -48,11 +48,12 @@ void TestingJsonParser::Start() { |
scoped_ptr<base::Value> value = base::JSONReader::ReadAndReturnError( |
unsafe_json_, base::JSON_PARSE_RFC, &error_code, &error); |
- // Run the callback asynchronously. |
+ // Run the callback asynchronously. Post the delete task first, so that the |
+ // completion callbacks may quit the run loop without leaking |this|. |
+ base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
base::MessageLoop::current()->PostTask( |
FROM_HERE, value ? base::Bind(success_callback_, base::Passed(&value)) |
: base::Bind(error_callback_, error)); |
- base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
Bernhard Bauer
2015/12/16 08:48:00
Hm… in principle we could also delete this object
Robert Sesek
2015/12/16 15:55:48
Yeah, that's true, but there's no real difference
|
} |
} // namespace |