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

Side by Side Diff: Source/modules/notifications/NotificationCenter.cpp

Issue 103083002: Decouple FileSystem and WebSQL callbacks from VoidCallback and it non-refcounted (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2012 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 case SecurityOrigin::AlwaysDeny: 67 case SecurityOrigin::AlwaysDeny:
68 return NotificationClient::PermissionDenied; 68 return NotificationClient::PermissionDenied;
69 case SecurityOrigin::Ask: 69 case SecurityOrigin::Ask:
70 return m_client->checkPermission(executionContext()); 70 return m_client->checkPermission(executionContext());
71 } 71 }
72 72
73 ASSERT_NOT_REACHED(); 73 ASSERT_NOT_REACHED();
74 return m_client->checkPermission(executionContext()); 74 return m_client->checkPermission(executionContext());
75 } 75 }
76 76
77 void NotificationCenter::requestPermission(PassRefPtr<VoidCallback> callback) 77 void NotificationCenter::requestPermission(PassOwnPtr<VoidCallback> callback)
78 { 78 {
79 if (!client() || !executionContext()) 79 if (!client() || !executionContext())
80 return; 80 return;
81 81
82 switch (executionContext()->securityOrigin()->canShowNotifications()) { 82 switch (executionContext()->securityOrigin()->canShowNotifications()) {
83 case SecurityOrigin::AlwaysAllow: 83 case SecurityOrigin::AlwaysAllow:
84 case SecurityOrigin::AlwaysDeny: { 84 case SecurityOrigin::AlwaysDeny: {
85 m_callbacks.add(NotificationRequestCallback::createAndStartTimer(this, c allback)); 85 m_callbacks.add(NotificationRequestCallback::createAndStartTimer(this, c allback));
86 return; 86 return;
87 } 87 }
(...skipping 12 matching lines...) Expand all
100 m_client->cancelRequestsForPermission(executionContext()); 100 m_client->cancelRequestsForPermission(executionContext());
101 m_client->clearNotifications(executionContext()); 101 m_client->clearNotifications(executionContext());
102 m_client = 0; 102 m_client = 0;
103 } 103 }
104 104
105 void NotificationCenter::requestTimedOut(NotificationCenter::NotificationRequest Callback* request) 105 void NotificationCenter::requestTimedOut(NotificationCenter::NotificationRequest Callback* request)
106 { 106 {
107 m_callbacks.remove(request); 107 m_callbacks.remove(request);
108 } 108 }
109 109
110 PassRefPtr<NotificationCenter::NotificationRequestCallback> NotificationCenter:: NotificationRequestCallback::createAndStartTimer(NotificationCenter* center, Pas sRefPtr<VoidCallback> callback) 110 PassRefPtr<NotificationCenter::NotificationRequestCallback> NotificationCenter:: NotificationRequestCallback::createAndStartTimer(NotificationCenter* center, Pas sOwnPtr<VoidCallback> callback)
111 { 111 {
112 RefPtr<NotificationCenter::NotificationRequestCallback> requestCallback = ad optRef(new NotificationCenter::NotificationRequestCallback(center, callback)); 112 RefPtr<NotificationCenter::NotificationRequestCallback> requestCallback = ad optRef(new NotificationCenter::NotificationRequestCallback(center, callback));
113 requestCallback->startTimer(); 113 requestCallback->startTimer();
114 return requestCallback.release(); 114 return requestCallback.release();
115 } 115 }
116 116
117 NotificationCenter::NotificationRequestCallback::NotificationRequestCallback(Not ificationCenter* center, PassRefPtr<VoidCallback> callback) 117 NotificationCenter::NotificationRequestCallback::NotificationRequestCallback(Not ificationCenter* center, PassOwnPtr<VoidCallback> callback)
118 : m_notificationCenter(center) 118 : m_notificationCenter(center)
119 , m_timer(this, &NotificationCenter::NotificationRequestCallback::timerFired ) 119 , m_timer(this, &NotificationCenter::NotificationRequestCallback::timerFired )
120 , m_callback(callback) 120 , m_callback(callback)
121 { 121 {
122 } 122 }
123 123
124 void NotificationCenter::NotificationRequestCallback::startTimer() 124 void NotificationCenter::NotificationRequestCallback::startTimer()
125 { 125 {
126 m_timer.startOneShot(0); 126 m_timer.startOneShot(0);
127 } 127 }
128 128
129 void NotificationCenter::NotificationRequestCallback::timerFired(Timer<Notificat ionCenter::NotificationRequestCallback>*) 129 void NotificationCenter::NotificationRequestCallback::timerFired(Timer<Notificat ionCenter::NotificationRequestCallback>*)
130 { 130 {
131 if (m_callback) 131 if (m_callback)
132 m_callback->handleEvent(); 132 m_callback->handleEvent();
133 m_notificationCenter->requestTimedOut(this); 133 m_notificationCenter->requestTimedOut(this);
134 } 134 }
135 135
136 } // namespace WebCore 136 } // namespace WebCore
137 137
138 #endif // ENABLE(LEGACY_NOTIFICATIONS) 138 #endif // ENABLE(LEGACY_NOTIFICATIONS)
OLDNEW
« no previous file with comments | « Source/modules/notifications/NotificationCenter.h ('k') | Source/modules/notifications/NotificationClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698