OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "content/browser/renderer_host/websocket_blob_sender.h" | 5 #include "content/browser/renderer_host/websocket_blob_sender.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/files/file.h" | 12 #include "base/files/file.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
15 #include "base/files/scoped_temp_dir.h" | 15 #include "base/files/scoped_temp_dir.h" |
16 #include "base/location.h" | 16 #include "base/location.h" |
17 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
20 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
| 21 #include "base/single_thread_task_runner.h" |
21 #include "base/task_runner.h" | 22 #include "base/task_runner.h" |
| 23 #include "base/threading/thread_task_runner_handle.h" |
22 #include "base/time/time.h" | 24 #include "base/time/time.h" |
23 #include "content/browser/blob_storage/chrome_blob_storage_context.h" | 25 #include "content/browser/blob_storage/chrome_blob_storage_context.h" |
24 #include "content/public/browser/blob_handle.h" | 26 #include "content/public/browser/blob_handle.h" |
25 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
26 #include "content/public/browser/storage_partition.h" | 28 #include "content/public/browser/storage_partition.h" |
27 #include "content/public/test/test_browser_context.h" | 29 #include "content/public/test/test_browser_context.h" |
28 #include "content/public/test/test_browser_thread_bundle.h" | 30 #include "content/public/test/test_browser_thread_bundle.h" |
29 #include "net/base/completion_callback.h" | 31 #include "net/base/completion_callback.h" |
30 #include "net/base/net_errors.h" | 32 #include "net/base/net_errors.h" |
31 #include "net/base/test_completion_callback.h" | 33 #include "net/base/test_completion_callback.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 size_t GetSendQuota() const override { return current_send_quota_; } | 66 size_t GetSendQuota() const override { return current_send_quota_; } |
65 | 67 |
66 ChannelState SendFrame(bool fin, const std::vector<char>& data) override { | 68 ChannelState SendFrame(bool fin, const std::vector<char>& data) override { |
67 ++frames_sent_; | 69 ++frames_sent_; |
68 EXPECT_FALSE(got_fin_); | 70 EXPECT_FALSE(got_fin_); |
69 if (fin) | 71 if (fin) |
70 got_fin_ = true; | 72 got_fin_ = true; |
71 EXPECT_LE(data.size(), current_send_quota_); | 73 EXPECT_LE(data.size(), current_send_quota_); |
72 message_.insert(message_.end(), data.begin(), data.end()); | 74 message_.insert(message_.end(), data.begin(), data.end()); |
73 current_send_quota_ -= data.size(); | 75 current_send_quota_ -= data.size(); |
74 base::MessageLoop::current()->PostTask( | 76 base::ThreadTaskRunnerHandle::Get()->PostTask( |
75 FROM_HERE, | 77 FROM_HERE, |
76 base::Bind(&FakeChannel::RefreshQuota, weak_factory_.GetWeakPtr())); | 78 base::Bind(&FakeChannel::RefreshQuota, weak_factory_.GetWeakPtr())); |
77 return net::WebSocketEventInterface::CHANNEL_ALIVE; | 79 return net::WebSocketEventInterface::CHANNEL_ALIVE; |
78 } | 80 } |
79 | 81 |
80 bool got_fin() const { return got_fin_; } | 82 bool got_fin() const { return got_fin_; } |
81 | 83 |
82 int frames_sent() const { return frames_sent_; } | 84 int frames_sent() const { return frames_sent_; } |
83 | 85 |
84 const std::vector<char>& message() const { return message_; } | 86 const std::vector<char>& message() const { return message_; } |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 | 441 |
440 int rv = Start(handle->GetUUID(), message.size(), NotCalled()); | 442 int rv = Start(handle->GetUUID(), message.size(), NotCalled()); |
441 EXPECT_EQ(net::OK, rv); | 443 EXPECT_EQ(net::OK, rv); |
442 std::vector<char> expected_message(message.begin(), message.end()); | 444 std::vector<char> expected_message(message.begin(), message.end()); |
443 EXPECT_EQ(expected_message, synchronous_fake_channel_->message()); | 445 EXPECT_EQ(expected_message, synchronous_fake_channel_->message()); |
444 } | 446 } |
445 | 447 |
446 } // namespace | 448 } // namespace |
447 | 449 |
448 } // namespace content | 450 } // namespace content |
OLD | NEW |