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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/BytesConsumerTestUtil.cpp

Issue 2749753002: Migrate WTF::Deque::removeFirst() to ::pop_front() (Closed)
Patch Set: Created 3 years, 9 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 // 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/BytesConsumerTestUtil.h" 5 #include "modules/fetch/BytesConsumerTestUtil.h"
6 6
7 #include "core/dom/ExecutionContext.h" 7 #include "core/dom/ExecutionContext.h"
8 #include "core/dom/TaskRunnerHelper.h" 8 #include "core/dom/TaskRunnerHelper.h"
9 #include "platform/WebTaskRunner.h" 9 #include "platform/WebTaskRunner.h"
10 #include "platform/testing/UnitTestHelpers.h" 10 #include "platform/testing/UnitTestHelpers.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 53 }
54 } 54 }
55 const Command& command = m_commands[0]; 55 const Command& command = m_commands[0];
56 switch (command.getName()) { 56 switch (command.getName()) {
57 case Command::Data: 57 case Command::Data:
58 DCHECK_LE(m_offset, command.body().size()); 58 DCHECK_LE(m_offset, command.body().size());
59 *buffer = command.body().data() + m_offset; 59 *buffer = command.body().data() + m_offset;
60 *available = command.body().size() - m_offset; 60 *available = command.body().size() - m_offset;
61 return Result::Ok; 61 return Result::Ok;
62 case Command::Done: 62 case Command::Done:
63 m_commands.removeFirst(); 63 m_commands.pop_front();
64 close(); 64 close();
65 return Result::Done; 65 return Result::Done;
66 case Command::Error: { 66 case Command::Error: {
67 Error e(String::fromUTF8(command.body().data(), command.body().size())); 67 Error e(String::fromUTF8(command.body().data(), command.body().size()));
68 m_commands.removeFirst(); 68 m_commands.pop_front();
69 error(std::move(e)); 69 error(std::move(e));
70 return Result::Error; 70 return Result::Error;
71 } 71 }
72 case Command::Wait: 72 case Command::Wait:
73 m_commands.removeFirst(); 73 m_commands.pop_front();
74 m_state = InternalState::Waiting; 74 m_state = InternalState::Waiting;
75 TaskRunnerHelper::get(TaskType::Networking, m_executionContext) 75 TaskRunnerHelper::get(TaskType::Networking, m_executionContext)
76 ->postTask(BLINK_FROM_HERE, 76 ->postTask(BLINK_FROM_HERE,
77 WTF::bind(&ReplayingBytesConsumer::notifyAsReadable, 77 WTF::bind(&ReplayingBytesConsumer::notifyAsReadable,
78 wrapPersistent(this), m_notificationToken)); 78 wrapPersistent(this), m_notificationToken));
79 return Result::ShouldWait; 79 return Result::ShouldWait;
80 } 80 }
81 NOTREACHED(); 81 NOTREACHED();
82 return Result::Error; 82 return Result::Error;
83 } 83 }
84 84
85 Result BytesConsumerTestUtil::ReplayingBytesConsumer::endRead(size_t read) { 85 Result BytesConsumerTestUtil::ReplayingBytesConsumer::endRead(size_t read) {
86 DCHECK(!m_commands.isEmpty()); 86 DCHECK(!m_commands.isEmpty());
87 const Command& command = m_commands[0]; 87 const Command& command = m_commands[0];
88 DCHECK_EQ(Command::Data, command.getName()); 88 DCHECK_EQ(Command::Data, command.getName());
89 m_offset += read; 89 m_offset += read;
90 DCHECK_LE(m_offset, command.body().size()); 90 DCHECK_LE(m_offset, command.body().size());
91 if (m_offset < command.body().size()) 91 if (m_offset < command.body().size())
92 return Result::Ok; 92 return Result::Ok;
93 93
94 m_offset = 0; 94 m_offset = 0;
95 m_commands.removeFirst(); 95 m_commands.pop_front();
96 return Result::Ok; 96 return Result::Ok;
97 } 97 }
98 98
99 void BytesConsumerTestUtil::ReplayingBytesConsumer::setClient(Client* client) { 99 void BytesConsumerTestUtil::ReplayingBytesConsumer::setClient(Client* client) {
100 DCHECK(!m_client); 100 DCHECK(!m_client);
101 DCHECK(client); 101 DCHECK(client);
102 m_client = client; 102 m_client = client;
103 ++m_notificationToken; 103 ++m_notificationToken;
104 } 104 }
105 105
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 BytesConsumerTestUtil::TwoPhaseReader::run() { 189 BytesConsumerTestUtil::TwoPhaseReader::run() {
190 onStateChange(); 190 onStateChange();
191 while (m_result != BytesConsumer::Result::Done && 191 while (m_result != BytesConsumer::Result::Done &&
192 m_result != BytesConsumer::Result::Error) 192 m_result != BytesConsumer::Result::Error)
193 testing::runPendingTasks(); 193 testing::runPendingTasks();
194 testing::runPendingTasks(); 194 testing::runPendingTasks();
195 return std::make_pair(m_result, std::move(m_data)); 195 return std::make_pair(m_result, std::move(m_data));
196 } 196 }
197 197
198 } // namespace blink 198 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698