OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/notifications/NotificationResourcesLoader.h" | 5 #include "modules/notifications/NotificationResourcesLoader.h" |
6 | 6 |
7 #include "platform/Histogram.h" | 7 #include "platform/Histogram.h" |
8 #include "platform/weborigin/KURL.h" | 8 #include "platform/weborigin/KURL.h" |
9 #include "public/platform/modules/notifications/WebNotificationData.h" | 9 #include "public/platform/modules/notifications/WebNotificationData.h" |
10 #include "public/platform/modules/notifications/WebNotificationResources.h" | 10 #include "public/platform/modules/notifications/WebNotificationResources.h" |
11 #include "wtf/CurrentTime.h" | 11 #include "wtf/CurrentTime.h" |
12 #include "wtf/Threading.h" | 12 #include "wtf/Threading.h" |
13 #include <cmath> | 13 #include <cmath> |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 NotificationResourcesLoader::NotificationResourcesLoader( | 17 NotificationResourcesLoader::NotificationResourcesLoader( |
18 std::unique_ptr<CompletionCallback> completionCallback) | 18 std::unique_ptr<CompletionCallback> completionCallback) |
19 : m_started(false), | 19 : m_started(false), |
20 m_completionCallback(std::move(completionCallback)), | 20 m_completionCallback(std::move(completionCallback)), |
21 m_pendingRequestCount(0) { | 21 m_pendingRequestCount(0) { |
22 ThreadState::current()->registerPreFinalizer(this); | |
23 DCHECK(m_completionCallback); | 22 DCHECK(m_completionCallback); |
24 } | 23 } |
25 | 24 |
26 NotificationResourcesLoader::~NotificationResourcesLoader() {} | 25 NotificationResourcesLoader::~NotificationResourcesLoader() {} |
27 | 26 |
28 void NotificationResourcesLoader::start( | 27 void NotificationResourcesLoader::start( |
29 ExecutionContext* executionContext, | 28 ExecutionContext* executionContext, |
30 const WebNotificationData& notificationData) { | 29 const WebNotificationData& notificationData) { |
31 DCHECK(!m_started); | 30 DCHECK(!m_started); |
32 m_started = true; | 31 m_started = true; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 DCHECK_GT(m_pendingRequestCount, 0); | 122 DCHECK_GT(m_pendingRequestCount, 0); |
124 m_pendingRequestCount--; | 123 m_pendingRequestCount--; |
125 if (!m_pendingRequestCount) { | 124 if (!m_pendingRequestCount) { |
126 stop(); | 125 stop(); |
127 (*m_completionCallback)(this); | 126 (*m_completionCallback)(this); |
128 // The |this| pointer may have been deleted now. | 127 // The |this| pointer may have been deleted now. |
129 } | 128 } |
130 } | 129 } |
131 | 130 |
132 } // namespace blink | 131 } // namespace blink |
OLD | NEW |