OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/child/web_data_consumer_handle_impl.h" | 5 #include "content/child/web_data_consumer_handle_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <limits> |
| 9 #include <utility> |
8 | 10 |
9 #include <limits> | |
10 #include "base/bind.h" | 11 #include "base/bind.h" |
11 #include "base/logging.h" | 12 #include "base/logging.h" |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "mojo/public/c/system/types.h" | 14 #include "mojo/public/c/system/types.h" |
14 | 15 |
15 namespace content { | 16 namespace content { |
16 | 17 |
17 using Result = blink::WebDataConsumerHandle::Result; | 18 using Result = blink::WebDataConsumerHandle::Result; |
18 | 19 |
19 class WebDataConsumerHandleImpl::Context | 20 class WebDataConsumerHandleImpl::Context |
20 : public base::RefCountedThreadSafe<Context> { | 21 : public base::RefCountedThreadSafe<Context> { |
21 public: | 22 public: |
22 explicit Context(Handle handle) : handle_(handle.Pass()) {} | 23 explicit Context(Handle handle) : handle_(std::move(handle)) {} |
23 | 24 |
24 const Handle& handle() { return handle_; } | 25 const Handle& handle() { return handle_; } |
25 | 26 |
26 private: | 27 private: |
27 friend class base::RefCountedThreadSafe<Context>; | 28 friend class base::RefCountedThreadSafe<Context>; |
28 ~Context() {} | 29 ~Context() {} |
29 Handle handle_; | 30 Handle handle_; |
30 | 31 |
31 DISALLOW_COPY_AND_ASSIGN(Context); | 32 DISALLOW_COPY_AND_ASSIGN(Context); |
32 }; | 33 }; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 MOJO_DEADLINE_INDEFINITE, | 115 MOJO_DEADLINE_INDEFINITE, |
115 base::Bind(&ReaderImpl::OnHandleGotReadable, base::Unretained(this))); | 116 base::Bind(&ReaderImpl::OnHandleGotReadable, base::Unretained(this))); |
116 } | 117 } |
117 | 118 |
118 void WebDataConsumerHandleImpl::ReaderImpl::OnHandleGotReadable(MojoResult) { | 119 void WebDataConsumerHandleImpl::ReaderImpl::OnHandleGotReadable(MojoResult) { |
119 DCHECK(client_); | 120 DCHECK(client_); |
120 client_->didGetReadable(); | 121 client_->didGetReadable(); |
121 } | 122 } |
122 | 123 |
123 WebDataConsumerHandleImpl::WebDataConsumerHandleImpl(Handle handle) | 124 WebDataConsumerHandleImpl::WebDataConsumerHandleImpl(Handle handle) |
124 : context_(new Context(handle.Pass())) { | 125 : context_(new Context(std::move(handle))) {} |
125 } | |
126 | 126 |
127 WebDataConsumerHandleImpl::~WebDataConsumerHandleImpl() { | 127 WebDataConsumerHandleImpl::~WebDataConsumerHandleImpl() { |
128 } | 128 } |
129 | 129 |
130 scoped_ptr<blink::WebDataConsumerHandle::Reader> | 130 scoped_ptr<blink::WebDataConsumerHandle::Reader> |
131 WebDataConsumerHandleImpl::ObtainReader(Client* client) { | 131 WebDataConsumerHandleImpl::ObtainReader(Client* client) { |
132 return make_scoped_ptr(obtainReaderInternal(client)); | 132 return make_scoped_ptr(obtainReaderInternal(client)); |
133 } | 133 } |
134 | 134 |
135 WebDataConsumerHandleImpl::ReaderImpl* | 135 WebDataConsumerHandleImpl::ReaderImpl* |
136 WebDataConsumerHandleImpl::obtainReaderInternal(Client* client) { | 136 WebDataConsumerHandleImpl::obtainReaderInternal(Client* client) { |
137 return new ReaderImpl(context_, client); | 137 return new ReaderImpl(context_, client); |
138 } | 138 } |
139 | 139 |
140 const char* WebDataConsumerHandleImpl::debugName() const { | 140 const char* WebDataConsumerHandleImpl::debugName() const { |
141 return "WebDataConsumerHandleImpl"; | 141 return "WebDataConsumerHandleImpl"; |
142 } | 142 } |
143 | 143 |
144 } // namespace content | 144 } // namespace content |
OLD | NEW |