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: chrome/browser/extensions/api/file_system/file_system_apitest_chromeos.cc

Issue 2887293003: Modernize some extensions code. (Closed)
Patch Set: address comments Created 3 years, 7 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 | « no previous file | chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/file_system/file_system_apitest_chromeos.cc
diff --git a/chrome/browser/extensions/api/file_system/file_system_apitest_chromeos.cc b/chrome/browser/extensions/api/file_system/file_system_apitest_chromeos.cc
index c96373adcb7c1edeeffe304f41d201757239b9ca..180ed24a5274e8da7479c43982940a395d80d5b9 100644
--- a/chrome/browser/extensions/api/file_system/file_system_apitest_chromeos.cc
+++ b/chrome/browser/extensions/api/file_system/file_system_apitest_chromeos.cc
@@ -80,19 +80,21 @@ class ScopedAddListenerObserver : public EventRouter::Observer {
callback_(callback),
event_router_(EventRouter::EventRouter::Get(profile)) {
DCHECK(profile);
- DCHECK(event_router_);
event_router_->RegisterObserver(this, event_name);
}
- ~ScopedAddListenerObserver() { event_router_->UnregisterObserver(this); }
+ ~ScopedAddListenerObserver() override {
+ event_router_->UnregisterObserver(this);
+ }
// EventRouter::Observer overrides.
void OnListenerAdded(const EventListenerInfo& details) override {
// Call the callback only once, as the listener may be added multiple times.
- if (details.extension_id == extension_id_ && !callback_.is_null()) {
- base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback_);
- callback_ = base::Closure();
- }
+ if (details.extension_id != extension_id_ || !callback_)
+ return;
+
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::ResetAndReturn(&callback_));
}
private:
« no previous file with comments | « no previous file | chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698