| 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/DataConsumerTee.h" | 5 #include "modules/fetch/DataConsumerTee.h" |
| 6 | 6 |
| 7 #include "core/dom/ActiveDOMObject.h" | 7 #include "core/dom/ActiveDOMObject.h" |
| 8 #include "core/dom/ExecutionContext.h" | 8 #include "core/dom/ExecutionContext.h" |
| 9 #include "modules/fetch/DataConsumerHandleUtil.h" | 9 #include "modules/fetch/DataConsumerHandleUtil.h" |
| 10 #include "modules/fetch/FetchBlobDataConsumerHandle.h" | 10 #include "modules/fetch/FetchBlobDataConsumerHandle.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 } | 101 } |
| 102 | 102 |
| 103 private: | 103 private: |
| 104 TeeRootObject() = default; | 104 TeeRootObject() = default; |
| 105 | 105 |
| 106 CrossThreadPersistent<SourceContext> m_sourceContext; | 106 CrossThreadPersistent<SourceContext> m_sourceContext; |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 class DestinationTracker final : public ThreadSafeRefCounted<DestinationTracker>
{ | 109 class DestinationTracker final : public ThreadSafeRefCounted<DestinationTracker>
{ |
| 110 public: | 110 public: |
| 111 static PassRefPtr<DestinationTracker> create(PassRefPtr<TeeRootObject> root)
{ return adoptRef(new DestinationTracker(root)); } | 111 static PassRefPtr<DestinationTracker> create(PassRefPtr<TeeRootObject> root)
{ return adoptRef(new DestinationTracker(std::move(root))); } |
| 112 ~DestinationTracker() | 112 ~DestinationTracker() |
| 113 { | 113 { |
| 114 m_root->stop(); | 114 m_root->stop(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 private: | 117 private: |
| 118 explicit DestinationTracker(PassRefPtr<TeeRootObject> root) : m_root(root) {
} | 118 explicit DestinationTracker(PassRefPtr<TeeRootObject> root) : m_root(root) {
} |
| 119 | 119 |
| 120 RefPtr<TeeRootObject> m_root; | 120 RefPtr<TeeRootObject> m_root; |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 class DestinationContext final : public ThreadSafeRefCounted<DestinationContext>
{ | 123 class DestinationContext final : public ThreadSafeRefCounted<DestinationContext>
{ |
| 124 public: | 124 public: |
| 125 class Proxy : public ThreadSafeRefCounted<Proxy> { | 125 class Proxy : public ThreadSafeRefCounted<Proxy> { |
| 126 public: | 126 public: |
| 127 static PassRefPtr<Proxy> create(PassRefPtr<DestinationContext> context,
PassRefPtr<DestinationTracker> tracker) | 127 static PassRefPtr<Proxy> create(PassRefPtr<DestinationContext> context,
PassRefPtr<DestinationTracker> tracker) |
| 128 { | 128 { |
| 129 return adoptRef(new Proxy(context, tracker)); | 129 return adoptRef(new Proxy(std::move(context), std::move(tracker))); |
| 130 } | 130 } |
| 131 ~Proxy() | 131 ~Proxy() |
| 132 { | 132 { |
| 133 m_context->detach(); | 133 m_context->detach(); |
| 134 } | 134 } |
| 135 | 135 |
| 136 DestinationContext* context() { return m_context.get(); } | 136 DestinationContext* context() { return m_context.get(); } |
| 137 | 137 |
| 138 private: | 138 private: |
| 139 Proxy(PassRefPtr<DestinationContext> context, PassRefPtr<DestinationTrac
ker> tracker) : m_context(context), m_tracker(tracker) { } | 139 Proxy(PassRefPtr<DestinationContext> context, PassRefPtr<DestinationTrac
ker> tracker) : m_context(context), m_tracker(tracker) { } |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 private: | 307 private: |
| 308 DestinationContext* context() { return m_contextProxy->context(); } | 308 DestinationContext* context() { return m_contextProxy->context(); } |
| 309 | 309 |
| 310 RefPtr<DestinationContext::Proxy> m_contextProxy; | 310 RefPtr<DestinationContext::Proxy> m_contextProxy; |
| 311 }; | 311 }; |
| 312 | 312 |
| 313 class DestinationHandle final : public WebDataConsumerHandle { | 313 class DestinationHandle final : public WebDataConsumerHandle { |
| 314 public: | 314 public: |
| 315 static std::unique_ptr<WebDataConsumerHandle> create(PassRefPtr<DestinationC
ontext::Proxy> contextProxy) | 315 static std::unique_ptr<WebDataConsumerHandle> create(PassRefPtr<DestinationC
ontext::Proxy> contextProxy) |
| 316 { | 316 { |
| 317 return wrapUnique(new DestinationHandle(contextProxy)); | 317 return wrapUnique(new DestinationHandle(std::move(contextProxy))); |
| 318 } | 318 } |
| 319 | 319 |
| 320 std::unique_ptr<Reader> obtainReader(Client* client) | 320 std::unique_ptr<Reader> obtainReader(Client* client) |
| 321 { | 321 { |
| 322 return wrapUnique(new DestinationReader(m_contextProxy, client)); | 322 return wrapUnique(new DestinationReader(m_contextProxy, client)); |
| 323 } | 323 } |
| 324 | 324 |
| 325 private: | 325 private: |
| 326 DestinationHandle(PassRefPtr<DestinationContext::Proxy> contextProxy) : m_co
ntextProxy(contextProxy) { } | 326 DestinationHandle(PassRefPtr<DestinationContext::Proxy> contextProxy) : m_co
ntextProxy(contextProxy) { } |
| 327 const char* debugName() const override { return "DestinationHandle"; } | 327 const char* debugName() const override { return "DestinationHandle"; } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 } | 430 } |
| 431 | 431 |
| 432 std::unique_ptr<WebDataConsumerHandle> webDest1, webDest2; | 432 std::unique_ptr<WebDataConsumerHandle> webDest1, webDest2; |
| 433 DataConsumerTee::create(executionContext, static_cast<std::unique_ptr<WebDat
aConsumerHandle>>(std::move(src)), &webDest1, &webDest2); | 433 DataConsumerTee::create(executionContext, static_cast<std::unique_ptr<WebDat
aConsumerHandle>>(std::move(src)), &webDest1, &webDest2); |
| 434 *dest1 = createFetchDataConsumerHandleFromWebHandle(std::move(webDest1)); | 434 *dest1 = createFetchDataConsumerHandleFromWebHandle(std::move(webDest1)); |
| 435 *dest2 = createFetchDataConsumerHandleFromWebHandle(std::move(webDest2)); | 435 *dest2 = createFetchDataConsumerHandleFromWebHandle(std::move(webDest2)); |
| 436 return; | 436 return; |
| 437 } | 437 } |
| 438 | 438 |
| 439 } // namespace blink | 439 } // namespace blink |
| OLD | NEW |