| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/fetch/DataConsumerHandleUtil.h" | 5 #include "modules/fetch/DataConsumerHandleUtil.h" |
| 6 | 6 |
| 7 #include "platform/Task.h" | |
| 8 #include "platform/blob/BlobData.h" | 7 #include "platform/blob/BlobData.h" |
| 9 #include "public/platform/Platform.h" | 8 #include "public/platform/Platform.h" |
| 9 #include "public/platform/WebTaskRunner.h" |
| 10 #include "public/platform/WebThread.h" | 10 #include "public/platform/WebThread.h" |
| 11 #include "public/platform/WebTraceLocation.h" | 11 #include "public/platform/WebTraceLocation.h" |
| 12 #include "wtf/Functional.h" | 12 #include "wtf/Functional.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 using Result = WebDataConsumerHandle::Result; | 16 using Result = WebDataConsumerHandle::Result; |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 return adoptPtr(new WebToFetchDataConsumerHandleAdapter(handle)); | 122 return adoptPtr(new WebToFetchDataConsumerHandleAdapter(handle)); |
| 123 } | 123 } |
| 124 | 124 |
| 125 NotifyOnReaderCreationHelper::NotifyOnReaderCreationHelper(WebDataConsumerHandle
::Client* client) | 125 NotifyOnReaderCreationHelper::NotifyOnReaderCreationHelper(WebDataConsumerHandle
::Client* client) |
| 126 : m_factory(this) | 126 : m_factory(this) |
| 127 { | 127 { |
| 128 if (!client) | 128 if (!client) |
| 129 return; | 129 return; |
| 130 // Note we don't need thread safety here because this object is | 130 // Note we don't need thread safety here because this object is |
| 131 // bound to the current thread. | 131 // bound to the current thread. |
| 132 Platform::current()->currentThread()->taskRunner()->postTask(BLINK_FROM_HERE
, new Task(bind(&NotifyOnReaderCreationHelper::notify, m_factory.createWeakPtr()
, client))); | 132 Platform::current()->currentThread()->taskRunner()->postTask(BLINK_FROM_HERE
, bind(&NotifyOnReaderCreationHelper::notify, m_factory.createWeakPtr(), client)
); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void NotifyOnReaderCreationHelper::notify(WebDataConsumerHandle::Client* client) | 135 void NotifyOnReaderCreationHelper::notify(WebDataConsumerHandle::Client* client) |
| 136 { | 136 { |
| 137 // |client| dereference is safe here because: | 137 // |client| dereference is safe here because: |
| 138 // - |this| is owned by a reader, | 138 // - |this| is owned by a reader, |
| 139 // so the reader outlives |this|, and | 139 // so the reader outlives |this|, and |
| 140 // - |client| is the client of the reader, so |client| outlives the reader | 140 // - |client| is the client of the reader, so |client| outlives the reader |
| 141 // (guaranteed by the user of the reader), | 141 // (guaranteed by the user of the reader), |
| 142 // and therefore |client| outlives |this|. | 142 // and therefore |client| outlives |this|. |
| 143 client->didGetReadable(); | 143 client->didGetReadable(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 } // namespace blink | 146 } // namespace blink |
| OLD | NEW |