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

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

Issue 2583093002: Reduce SuspendableObjects (Closed)
Patch Set: Created 4 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 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 106 }
107 107
108 WebNotificationData data = 108 WebNotificationData data =
109 createWebNotificationData(context, title, options, exceptionState); 109 createWebNotificationData(context, title, options, exceptionState);
110 if (exceptionState.hadException()) 110 if (exceptionState.hadException())
111 return nullptr; 111 return nullptr;
112 112
113 Notification* notification = 113 Notification* notification =
114 new Notification(context, Type::NonPersistent, data); 114 new Notification(context, Type::NonPersistent, data);
115 notification->schedulePrepareShow(); 115 notification->schedulePrepareShow();
116
117 notification->suspendIfNeeded();
118 return notification; 116 return notification;
119 } 117 }
120 118
121 Notification* Notification::create(ExecutionContext* context, 119 Notification* Notification::create(ExecutionContext* context,
122 const String& notificationId, 120 const String& notificationId,
123 const WebNotificationData& data, 121 const WebNotificationData& data,
124 bool showing) { 122 bool showing) {
125 Notification* notification = 123 Notification* notification =
126 new Notification(context, Type::Persistent, data); 124 new Notification(context, Type::Persistent, data);
127 notification->setState(showing ? State::Showing : State::Closed); 125 notification->setState(showing ? State::Showing : State::Closed);
128 notification->setNotificationId(notificationId); 126 notification->setNotificationId(notificationId);
129
130 notification->suspendIfNeeded();
131 return notification; 127 return notification;
132 } 128 }
133 129
134 Notification::Notification(ExecutionContext* context, 130 Notification::Notification(ExecutionContext* context,
135 Type type, 131 Type type,
136 const WebNotificationData& data) 132 const WebNotificationData& data)
137 : SuspendableObject(context), 133 : ContextLifecycleObserver(context),
138 m_type(type), 134 m_type(type),
139 m_state(State::Loading), 135 m_state(State::Loading),
140 m_data(data) { 136 m_data(data) {
141 DCHECK(notificationManager()); 137 DCHECK(notificationManager());
142 } 138 }
143 139
144 Notification::~Notification() {} 140 Notification::~Notification() {}
145 141
146 void Notification::schedulePrepareShow() { 142 void Notification::schedulePrepareShow() {
147 DCHECK_EQ(m_state, State::Loading); 143 DCHECK_EQ(m_state, State::Loading);
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 if (m_type == Type::NonPersistent) 393 if (m_type == Type::NonPersistent)
398 return m_state != State::Closed; 394 return m_state != State::Closed;
399 395
400 return false; 396 return false;
401 } 397 }
402 398
403 DEFINE_TRACE(Notification) { 399 DEFINE_TRACE(Notification) {
404 visitor->trace(m_prepareShowMethodRunner); 400 visitor->trace(m_prepareShowMethodRunner);
405 visitor->trace(m_loader); 401 visitor->trace(m_loader);
406 EventTargetWithInlineData::trace(visitor); 402 EventTargetWithInlineData::trace(visitor);
407 SuspendableObject::trace(visitor); 403 ContextLifecycleObserver::trace(visitor);
408 } 404 }
409 405
410 } // namespace blink 406 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698