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

Side by Side Diff: net/socket/socket_bio_adapter.cc

Issue 2414883005: TEMP DO NOT LAND (Closed)
Patch Set: tmp Created 4 years, 1 month 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 | « net/socket/socket_bio_adapter.h ('k') | net/socket/ssl_client_socket_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "net/socket/socket_bio_adapter.h" 5 #include "net/socket/socket_bio_adapter.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
15 #include "net/base/io_buffer.h" 15 #include "net/base/io_buffer.h"
16 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
17 #include "net/socket/stream_socket.h" 17 #include "net/socket/stream_socket.h"
18 #include "net/ssl/openssl_ssl_util.h" 18 #include "net/ssl/openssl_ssl_util.h"
19 #include "third_party/boringssl/src/include/openssl/bio.h" 19 #include "third_party/boringssl/src/include/openssl/bio.h"
20 20
21 #include "base/trace_event/memory_allocator_dump.h"
22 #include "base/trace_event/process_memory_dump.h"
23 #include "base/strings/stringprintf.h"
24
21 namespace net { 25 namespace net {
22 26
23 SocketBIOAdapter::SocketBIOAdapter(StreamSocket* socket, 27 SocketBIOAdapter::SocketBIOAdapter(StreamSocket* socket,
24 int read_buffer_capacity, 28 int read_buffer_capacity,
25 int write_buffer_capacity, 29 int write_buffer_capacity,
26 Delegate* delegate) 30 Delegate* delegate)
27 : socket_(socket), 31 : socket_(socket),
28 read_buffer_capacity_(read_buffer_capacity), 32 read_buffer_capacity_(read_buffer_capacity),
29 read_offset_(0), 33 read_offset_(0),
30 read_result_(0), 34 read_result_(0),
(...skipping 15 matching lines...) Expand all
46 SocketBIOAdapter::~SocketBIOAdapter() { 50 SocketBIOAdapter::~SocketBIOAdapter() {
47 // BIOs are reference-counted and may outlive the adapter. Clear the pointer 51 // BIOs are reference-counted and may outlive the adapter. Clear the pointer
48 // so future operations fail. 52 // so future operations fail.
49 bio_->ptr = nullptr; 53 bio_->ptr = nullptr;
50 } 54 }
51 55
52 bool SocketBIOAdapter::HasPendingReadData() { 56 bool SocketBIOAdapter::HasPendingReadData() {
53 return read_result_ > 0; 57 return read_result_ > 0;
54 } 58 }
55 59
60 size_t SocketBIOAdapter::GetEffectiveSize() const {
61 size_t effective_size = 0;
62 if (read_buffer_)
63 effective_size+=read_buffer_capacity_;
64
65 if (write_buffer_)
66 effective_size+= write_buffer_capacity_;
67 return effective_size;
68 }
69
56 int SocketBIOAdapter::BIORead(char* out, int len) { 70 int SocketBIOAdapter::BIORead(char* out, int len) {
57 if (len <= 0) 71 if (len <= 0)
58 return len; 72 return len;
59 73
60 // If there is no result available synchronously, report any Write() errors 74 // If there is no result available synchronously, report any Write() errors
61 // that were observed. Otherwise the application may have encountered a socket 75 // that were observed. Otherwise the application may have encountered a socket
62 // error while writing that would otherwise not be reported until the 76 // error while writing that would otherwise not be reported until the
63 // application attempted to write again - which it may never do. See 77 // application attempted to write again - which it may never do. See
64 // https://crbug.com/249848. 78 // https://crbug.com/249848.
65 if (write_error_ != OK && write_error_ != ERR_IO_PENDING && 79 if (write_error_ != OK && write_error_ != ERR_IO_PENDING &&
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 SocketBIOAdapter::BIOReadWrapper, 345 SocketBIOAdapter::BIOReadWrapper,
332 nullptr, // puts 346 nullptr, // puts
333 nullptr, // gets 347 nullptr, // gets
334 SocketBIOAdapter::BIOCtrlWrapper, 348 SocketBIOAdapter::BIOCtrlWrapper,
335 nullptr, // create 349 nullptr, // create
336 nullptr, // destroy 350 nullptr, // destroy
337 nullptr, // callback_ctrl 351 nullptr, // callback_ctrl
338 }; 352 };
339 353
340 } // namespace net 354 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/socket_bio_adapter.h ('k') | net/socket/ssl_client_socket_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698