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

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

Issue 1976083002: Make ImageLoader::Task non-WebTaskRunner::Task (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Shironeko_1
Patch Set: Rebase. Created 4 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights reserv ed. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights reserv ed.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 static ImageLoader::BypassMainWorldBehavior shouldBypassMainWorldCSP(ImageLoader * loader) 74 static ImageLoader::BypassMainWorldBehavior shouldBypassMainWorldCSP(ImageLoader * loader)
75 { 75 {
76 ASSERT(loader); 76 ASSERT(loader);
77 ASSERT(loader->element()); 77 ASSERT(loader->element());
78 if (loader->element()->document().frame() && loader->element()->document().f rame()->script().shouldBypassMainWorldCSP()) 78 if (loader->element()->document().frame() && loader->element()->document().f rame()->script().shouldBypassMainWorldCSP())
79 return ImageLoader::BypassMainWorldCSP; 79 return ImageLoader::BypassMainWorldCSP;
80 return ImageLoader::DoNotBypassMainWorldCSP; 80 return ImageLoader::DoNotBypassMainWorldCSP;
81 } 81 }
82 82
83 class ImageLoader::Task : public WebTaskRunner::Task { 83 class ImageLoader::Task {
84 public: 84 public:
85 static std::unique_ptr<Task> create(ImageLoader* loader, UpdateFromElementBe havior updateBehavior, ReferrerPolicy referrerPolicy) 85 static std::unique_ptr<Task> create(ImageLoader* loader, UpdateFromElementBe havior updateBehavior, ReferrerPolicy referrerPolicy)
86 { 86 {
87 return wrapUnique(new Task(loader, updateBehavior, referrerPolicy)); 87 return wrapUnique(new Task(loader, updateBehavior, referrerPolicy));
88 } 88 }
89 89
90 Task(ImageLoader* loader, UpdateFromElementBehavior updateBehavior, Referrer Policy referrerPolicy) 90 Task(ImageLoader* loader, UpdateFromElementBehavior updateBehavior, Referrer Policy referrerPolicy)
91 : m_loader(loader) 91 : m_loader(loader)
92 , m_shouldBypassMainWorldCSP(shouldBypassMainWorldCSP(loader)) 92 , m_shouldBypassMainWorldCSP(shouldBypassMainWorldCSP(loader))
93 , m_updateBehavior(updateBehavior) 93 , m_updateBehavior(updateBehavior)
94 , m_weakFactory(this) 94 , m_weakFactory(this)
95 , m_referrerPolicy(referrerPolicy) 95 , m_referrerPolicy(referrerPolicy)
96 { 96 {
97 ExecutionContext& context = m_loader->element()->document(); 97 ExecutionContext& context = m_loader->element()->document();
98 InspectorInstrumentation::asyncTaskScheduled(&context, "Image", this); 98 InspectorInstrumentation::asyncTaskScheduled(&context, "Image", this);
99 v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate(); 99 v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate();
100 v8::HandleScope scope(isolate); 100 v8::HandleScope scope(isolate);
101 // If we're invoked from C++ without a V8 context on the stack, we shoul d 101 // If we're invoked from C++ without a V8 context on the stack, we shoul d
102 // run the microtask in the context of the element's document's main wor ld. 102 // run the microtask in the context of the element's document's main wor ld.
103 if (ScriptState::hasCurrentScriptState(isolate)) { 103 if (ScriptState::hasCurrentScriptState(isolate)) {
104 m_scriptState = ScriptState::current(isolate); 104 m_scriptState = ScriptState::current(isolate);
105 } else { 105 } else {
106 m_scriptState = ScriptState::forMainWorld(loader->element()->documen t().frame()); 106 m_scriptState = ScriptState::forMainWorld(loader->element()->documen t().frame());
107 ASSERT(m_scriptState); 107 ASSERT(m_scriptState);
108 } 108 }
109 } 109 }
110 110
111 ~Task() override 111 void run()
112 {
113 }
114
115 void run() override
116 { 112 {
117 if (!m_loader) 113 if (!m_loader)
118 return; 114 return;
119 ExecutionContext& context = m_loader->element()->document(); 115 ExecutionContext& context = m_loader->element()->document();
120 InspectorInstrumentation::AsyncTask asyncTask(&context, this); 116 InspectorInstrumentation::AsyncTask asyncTask(&context, this);
121 if (m_scriptState->contextIsValid()) { 117 if (m_scriptState->contextIsValid()) {
122 ScriptState::Scope scope(m_scriptState.get()); 118 ScriptState::Scope scope(m_scriptState.get());
123 m_loader->doUpdateFromElement(m_shouldBypassMainWorldCSP, m_updateBe havior, m_referrerPolicy); 119 m_loader->doUpdateFromElement(m_shouldBypassMainWorldCSP, m_updateBe havior, m_referrerPolicy);
124 } else { 120 } else {
125 m_loader->doUpdateFromElement(m_shouldBypassMainWorldCSP, m_updateBe havior, m_referrerPolicy); 121 m_loader->doUpdateFromElement(m_shouldBypassMainWorldCSP, m_updateBe havior, m_referrerPolicy);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 239
244 inline void ImageLoader::clearFailedLoadURL() 240 inline void ImageLoader::clearFailedLoadURL()
245 { 241 {
246 m_failedLoadURL = AtomicString(); 242 m_failedLoadURL = AtomicString();
247 } 243 }
248 244
249 inline void ImageLoader::enqueueImageLoadingMicroTask(UpdateFromElementBehavior updateBehavior, ReferrerPolicy referrerPolicy) 245 inline void ImageLoader::enqueueImageLoadingMicroTask(UpdateFromElementBehavior updateBehavior, ReferrerPolicy referrerPolicy)
250 { 246 {
251 std::unique_ptr<Task> task = Task::create(this, updateBehavior, referrerPoli cy); 247 std::unique_ptr<Task> task = Task::create(this, updateBehavior, referrerPoli cy);
252 m_pendingTask = task->createWeakPtr(); 248 m_pendingTask = task->createWeakPtr();
253 Microtask::enqueueMicrotask(std::move(task)); 249 Microtask::enqueueMicrotask(WTF::bind(&Task::run, passed(std::move(task))));
254 m_loadDelayCounter = IncrementLoadEventDelayCount::create(m_element->documen t()); 250 m_loadDelayCounter = IncrementLoadEventDelayCount::create(m_element->documen t());
255 } 251 }
256 252
257 void ImageLoader::doUpdateFromElement(BypassMainWorldBehavior bypassBehavior, Up dateFromElementBehavior updateBehavior, ReferrerPolicy referrerPolicy) 253 void ImageLoader::doUpdateFromElement(BypassMainWorldBehavior bypassBehavior, Up dateFromElementBehavior updateBehavior, ReferrerPolicy referrerPolicy)
258 { 254 {
259 // FIXME: According to 255 // FIXME: According to
260 // http://www.whatwg.org/specs/web-apps/current-work/multipage/embedded-cont ent.html#the-img-element:the-img-element-55 256 // http://www.whatwg.org/specs/web-apps/current-work/multipage/embedded-cont ent.html#the-img-element:the-img-element-55
261 // When "update image" is called due to environment changes and the load fai ls, onerror should not be called. 257 // When "update image" is called due to environment changes and the load fai ls, onerror should not be called.
262 // That is currently not the case. 258 // That is currently not the case.
263 // 259 //
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 602
607 void ImageLoader::elementDidMoveToNewDocument() 603 void ImageLoader::elementDidMoveToNewDocument()
608 { 604 {
609 if (m_loadDelayCounter) 605 if (m_loadDelayCounter)
610 m_loadDelayCounter->documentChanged(m_element->document()); 606 m_loadDelayCounter->documentChanged(m_element->document());
611 clearFailedLoadURL(); 607 clearFailedLoadURL();
612 setImage(0); 608 setImage(0);
613 } 609 }
614 610
615 } // namespace blink 611 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698