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

Side by Side Diff: third_party/WebKit/Source/modules/push_messaging/PushEvent.cpp

Issue 1784583002: PushEvent.data should be NULL for empty payloads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/push_messaging/PushEvent.h" 5 #include "modules/push_messaging/PushEvent.h"
6 6
7 #include "modules/push_messaging/PushEventInit.h" 7 #include "modules/push_messaging/PushEventInit.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
11 PushEvent::PushEvent() 11 PushEvent::PushEvent()
12 : m_data(PushMessageData::create())
dgn 2016/03/09 21:22:25 Isn't that always creating empty data? shouldn't i
Peter Beverloo 2016/03/09 21:28:29 There's one call-site that can return a nullptr im
12 { 13 {
13 } 14 }
14 15
15 PushEvent::PushEvent(const AtomicString& type, PushMessageData* data, WaitUntilO bserver* observer) 16 PushEvent::PushEvent(const AtomicString& type, PushMessageData* data, WaitUntilO bserver* observer)
16 : ExtendableEvent(type, ExtendableEventInit(), observer) 17 : ExtendableEvent(type, ExtendableEventInit(), observer)
17 , m_data(data) 18 , m_data(data)
18 { 19 {
19 } 20 }
20 21
21 PushEvent::PushEvent(const AtomicString& type, const PushEventInit& initializer) 22 PushEvent::PushEvent(const AtomicString& type, const PushEventInit& initializer)
22 : ExtendableEvent(type, initializer) 23 : ExtendableEvent(type, initializer)
23 { 24 {
24 if (initializer.hasData()) 25 if (initializer.hasData())
25 m_data = PushMessageData::create(initializer.data()); 26 m_data = PushMessageData::create(initializer.data());
26 } 27 }
27 28
28 PushEvent::~PushEvent() 29 PushEvent::~PushEvent()
29 { 30 {
30 } 31 }
31 32
32 const AtomicString& PushEvent::interfaceName() const 33 const AtomicString& PushEvent::interfaceName() const
33 { 34 {
34 return EventNames::PushEvent; 35 return EventNames::PushEvent;
35 } 36 }
36 37
37 PushMessageData* PushEvent::data() 38 PushMessageData* PushEvent::data()
38 { 39 {
39 if (!m_data)
40 m_data = PushMessageData::create();
41
42 return m_data.get(); 40 return m_data.get();
43 } 41 }
44 42
45 DEFINE_TRACE(PushEvent) 43 DEFINE_TRACE(PushEvent)
46 { 44 {
47 visitor->trace(m_data); 45 visitor->trace(m_data);
48 ExtendableEvent::trace(visitor); 46 ExtendableEvent::trace(visitor);
49 } 47 }
50 48
51 } // namespace blink 49 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698