summaryrefslogtreecommitdiffstats
path: root/ppapi/tests/test_transport.cc
diff options
context:
space:
mode:
authorpolina@google.com <polina@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-30 21:42:37 +0000
committerpolina@google.com <polina@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-30 21:42:37 +0000
commit917e86adc3f824f518c999dcba20bfd4cbf18a18 (patch)
tree52fe38f61527360231c17a905015066fb5d34bba /ppapi/tests/test_transport.cc
parent9ae7b9195f0e06b64664bba52e9cc0e8b3470f56 (diff)
downloadchromium_src-917e86adc3f824f518c999dcba20bfd4cbf18a18.zip
chromium_src-917e86adc3f824f518c999dcba20bfd4cbf18a18.tar.gz
chromium_src-917e86adc3f824f518c999dcba20bfd4cbf18a18.tar.bz2
Add a flag field to PP_CompletionCallback to control if the callback should
always be invoked asynchronously on success or error or skipped if the operation can complete synchronously without blocking. Keep the default behavior as-is until clients update their code. Bump revisions of all interfaces that take callbacks as args. Update browser interface function implementations and C++ layer to force callbacks if sync option is not set. Change ppapi/tests to run tests involving callbacks with both flag options. BUG=79376 TEST=ppapi_tests + bots Review URL: http://codereview.chromium.org/6899055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91205 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/tests/test_transport.cc')
-rw-r--r--ppapi/tests/test_transport.cc21
1 files changed, 14 insertions, 7 deletions
diff --git a/ppapi/tests/test_transport.cc b/ppapi/tests/test_transport.cc
index fc41f17..d45112a 100644
--- a/ppapi/tests/test_transport.cc
+++ b/ppapi/tests/test_transport.cc
@@ -54,7 +54,7 @@ class StreamReader {
buffer_.resize(kReadBufferSize);
int result = transport_->Recv(
&buffer_[0], buffer_.size(),
- callback_factory_.NewCallback(&StreamReader::OnReadFinished));
+ callback_factory_.NewOptionalCallback(&StreamReader::OnReadFinished));
if (result > 0)
DidFinishRead(result);
else
@@ -104,7 +104,7 @@ bool TestTransport::Init() {
void TestTransport::RunTest() {
RUN_TEST(Create);
RUN_TEST(Connect);
- RUN_TEST(SendDataUdp);
+ RUN_TEST_FORCEASYNC(SendDataUdp);
RUN_TEST(SendDataTcp);
RUN_TEST(ConnectAndCloseUdp);
RUN_TEST(ConnectAndCloseTcp);
@@ -198,10 +198,15 @@ std::string TestTransport::TestSendDataUdp() {
// Put packet index in the beginning.
memcpy(&send_buffer[0], &i, sizeof(i));
- TestCompletionCallback send_cb(instance_->pp_instance());
- ASSERT_EQ(
- transport2_->Send(&send_buffer[0], send_buffer.size(), send_cb),
- static_cast<int>(send_buffer.size()));
+ TestCompletionCallback send_cb(instance_->pp_instance(), force_async_);
+ int32_t result = transport2_->Send(&send_buffer[0], send_buffer.size(),
+ send_cb);
+ if (force_async_) {
+ ASSERT_EQ(result, PP_OK_COMPLETIONPENDING);
+ ASSERT_EQ(send_cb.WaitForResult(), static_cast<int>(send_buffer.size()));
+ } else {
+ ASSERT_EQ(result, static_cast<int>(send_buffer.size()));
+ }
sent_packets[i] = send_buffer;
}
@@ -243,9 +248,11 @@ std::string TestTransport::TestSendDataTcp() {
int pos = 0;
while (pos < static_cast<int>(send_buffer.size())) {
- TestCompletionCallback send_cb(instance_->pp_instance());
+ TestCompletionCallback send_cb(instance_->pp_instance(), force_async_);
int result = transport2_->Send(
&send_buffer[0] + pos, send_buffer.size() - pos, send_cb);
+ if (force_async_)
+ ASSERT_EQ(result, PP_OK_COMPLETIONPENDING);
if (result == PP_OK_COMPLETIONPENDING)
result = send_cb.WaitForResult();
ASSERT_TRUE(result > 0);