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

Side by Side Diff: third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp

Issue 2177243002: Use per-frame TaskRunner instead of thread's default in DataConsumerHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@data_consumer_handle_unique_ptr
Patch Set: update Created 4 years, 4 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 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013, Intel Corporation 3 * Copyright (C) 2013, Intel Corporation
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #include <memory> 60 #include <memory>
61 61
62 namespace blink { 62 namespace blink {
63 63
64 namespace { 64 namespace {
65 65
66 class EmptyDataHandle final : public WebDataConsumerHandle { 66 class EmptyDataHandle final : public WebDataConsumerHandle {
67 private: 67 private:
68 class EmptyDataReader final : public WebDataConsumerHandle::Reader { 68 class EmptyDataReader final : public WebDataConsumerHandle::Reader {
69 public: 69 public:
70 explicit EmptyDataReader(WebDataConsumerHandle::Client* client) : m_fact ory(this) 70 explicit EmptyDataReader(WebDataConsumerHandle::Client* client, std::uni que_ptr<WebTaskRunner> readerTaskRunner) : m_factory(this)
71 { 71 {
72 Platform::current()->currentThread()->getWebTaskRunner()->postTask(B LINK_FROM_HERE, WTF::bind(&EmptyDataReader::notify, m_factory.createWeakPtr(), W TF::unretained(client))); 72 DCHECK(readerTaskRunner->runsTasksOnCurrentThread());
73 readerTaskRunner->postTask(BLINK_FROM_HERE, WTF::bind(&EmptyDataRead er::notify, m_factory.createWeakPtr(), WTF::unretained(client)));
73 } 74 }
74 private: 75 private:
75 Result beginRead(const void** buffer, WebDataConsumerHandle::Flags, size _t *available) override 76 Result beginRead(const void** buffer, WebDataConsumerHandle::Flags, size _t *available) override
76 { 77 {
77 *available = 0; 78 *available = 0;
78 *buffer = nullptr; 79 *buffer = nullptr;
79 return Done; 80 return Done;
80 } 81 }
81 Result endRead(size_t) override 82 Result endRead(size_t) override
82 { 83 {
83 return WebDataConsumerHandle::UnexpectedError; 84 return WebDataConsumerHandle::UnexpectedError;
84 } 85 }
85 void notify(WebDataConsumerHandle::Client* client) 86 void notify(WebDataConsumerHandle::Client* client)
86 { 87 {
87 client->didGetReadable(); 88 client->didGetReadable();
88 } 89 }
89 WeakPtrFactory<EmptyDataReader> m_factory; 90 WeakPtrFactory<EmptyDataReader> m_factory;
90 }; 91 };
91 92
92 std::unique_ptr<Reader> obtainReader(Client* client) override 93 std::unique_ptr<Reader> obtainReader(Client* client, std::unique_ptr<WebTask Runner> readerTaskRunner) override
93 { 94 {
94 return WTF::wrapUnique(new EmptyDataReader(client)); 95 return WTF::wrapUnique(new EmptyDataReader(client, std::move(readerTaskR unner)));
95 } 96 }
96 const char* debugName() const override { return "EmptyDataHandle"; } 97 const char* debugName() const override { return "EmptyDataHandle"; }
97 }; 98 };
98 99
99 // No-CORS requests are allowed for all these contexts, and plugin contexts with 100 // No-CORS requests are allowed for all these contexts, and plugin contexts with
100 // private permission when we set skipServiceWorker flag in PepperURLLoaderHost. 101 // private permission when we set skipServiceWorker flag in PepperURLLoaderHost.
101 bool IsNoCORSAllowedContext(WebURLRequest::RequestContext context, WebURLRequest ::SkipServiceWorker skipServiceWorker) 102 bool IsNoCORSAllowedContext(WebURLRequest::RequestContext context, WebURLRequest ::SkipServiceWorker skipServiceWorker)
102 { 103 {
103 switch (context) { 104 switch (context) {
104 case WebURLRequest::RequestContextAudio: 105 case WebURLRequest::RequestContextAudio:
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 return m_securityOrigin ? m_securityOrigin.get() : document().getSecurityOri gin(); 1016 return m_securityOrigin ? m_securityOrigin.get() : document().getSecurityOri gin();
1016 } 1017 }
1017 1018
1018 Document& DocumentThreadableLoader::document() const 1019 Document& DocumentThreadableLoader::document() const
1019 { 1020 {
1020 ASSERT(m_document); 1021 ASSERT(m_document);
1021 return *m_document; 1022 return *m_document;
1022 } 1023 }
1023 1024
1024 } // namespace blink 1025 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698