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

Side by Side Diff: third_party/WebKit/Source/modules/notifications/Notification.cpp

Issue 2698153003: Reduce createSameThreadTask usage in modules/ (Closed)
Patch Set: Move a static callback to an anonymous namespace Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 19 matching lines...) Expand all
30 30
31 #include "modules/notifications/Notification.h" 31 #include "modules/notifications/Notification.h"
32 32
33 #include "bindings/core/v8/ExceptionState.h" 33 #include "bindings/core/v8/ExceptionState.h"
34 #include "bindings/core/v8/ScriptState.h" 34 #include "bindings/core/v8/ScriptState.h"
35 #include "bindings/core/v8/SerializedScriptValueFactory.h" 35 #include "bindings/core/v8/SerializedScriptValueFactory.h"
36 #include "bindings/modules/v8/V8NotificationAction.h" 36 #include "bindings/modules/v8/V8NotificationAction.h"
37 #include "core/dom/Document.h" 37 #include "core/dom/Document.h"
38 #include "core/dom/DocumentUserGestureToken.h" 38 #include "core/dom/DocumentUserGestureToken.h"
39 #include "core/dom/ExecutionContext.h" 39 #include "core/dom/ExecutionContext.h"
40 #include "core/dom/ExecutionContextTask.h"
41 #include "core/dom/ScopedWindowFocusAllowedIndicator.h" 40 #include "core/dom/ScopedWindowFocusAllowedIndicator.h"
42 #include "core/dom/TaskRunnerHelper.h" 41 #include "core/dom/TaskRunnerHelper.h"
43 #include "core/events/Event.h" 42 #include "core/events/Event.h"
44 #include "core/frame/Deprecation.h" 43 #include "core/frame/Deprecation.h"
45 #include "core/frame/UseCounter.h" 44 #include "core/frame/UseCounter.h"
46 #include "core/inspector/InspectorInstrumentation.h" 45 #include "core/inspector/InspectorInstrumentation.h"
47 #include "modules/notifications/NotificationAction.h" 46 #include "modules/notifications/NotificationAction.h"
48 #include "modules/notifications/NotificationData.h" 47 #include "modules/notifications/NotificationData.h"
49 #include "modules/notifications/NotificationManager.h" 48 #include "modules/notifications/NotificationManager.h"
50 #include "modules/notifications/NotificationOptions.h" 49 #include "modules/notifications/NotificationOptions.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 m_state = State::Showing; 177 m_state = State::Showing;
179 } 178 }
180 179
181 void Notification::close() { 180 void Notification::close() {
182 if (m_state != State::Showing) 181 if (m_state != State::Showing)
183 return; 182 return;
184 183
185 // Schedule the "close" event to be fired for non-persistent notifications. 184 // Schedule the "close" event to be fired for non-persistent notifications.
186 // Persistent notifications won't get such events for programmatic closes. 185 // Persistent notifications won't get such events for programmatic closes.
187 if (m_type == Type::NonPersistent) { 186 if (m_type == Type::NonPersistent) {
188 getExecutionContext()->postTask( 187 TaskRunnerHelper::get(TaskType::UserInteraction, getExecutionContext())
189 TaskType::UserInteraction, BLINK_FROM_HERE, 188 ->postTask(BLINK_FROM_HERE, WTF::bind(&Notification::dispatchCloseEvent,
190 createSameThreadTask(&Notification::dispatchCloseEvent, 189 wrapPersistent(this)));
191 wrapPersistent(this)));
192 m_state = State::Closing; 190 m_state = State::Closing;
193 191
194 notificationManager()->close(this); 192 notificationManager()->close(this);
195 return; 193 return;
196 } 194 }
197 195
198 m_state = State::Closed; 196 m_state = State::Closed;
199 197
200 SecurityOrigin* origin = getExecutionContext()->getSecurityOrigin(); 198 SecurityOrigin* origin = getExecutionContext()->getSecurityOrigin();
201 DCHECK(origin); 199 DCHECK(origin);
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 } 414 }
417 415
418 DEFINE_TRACE(Notification) { 416 DEFINE_TRACE(Notification) {
419 visitor->trace(m_prepareShowMethodRunner); 417 visitor->trace(m_prepareShowMethodRunner);
420 visitor->trace(m_loader); 418 visitor->trace(m_loader);
421 EventTargetWithInlineData::trace(visitor); 419 EventTargetWithInlineData::trace(visitor);
422 ContextLifecycleObserver::trace(visitor); 420 ContextLifecycleObserver::trace(visitor);
423 } 421 }
424 422
425 } // namespace blink 423 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698