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

Unified Diff: components/safe_json/testing_json_parser.cc

Issue 1527063002: Fix a leak in TestingJsonParser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: With fix Created 5 years 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 | « components/components_tests.gyp ('k') | components/safe_json/testing_json_parser_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « components/components_tests.gyp ('k') | components/safe_json/testing_json_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698