| 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 #ifndef MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // Returns the version number of the interface that the remote side supports. | 99 // Returns the version number of the interface that the remote side supports. |
| 100 uint32_t version() const { return internal_state_.version(); } | 100 uint32_t version() const { return internal_state_.version(); } |
| 101 | 101 |
| 102 // Queries the max version that the remote side supports. On completion, the | 102 // Queries the max version that the remote side supports. On completion, the |
| 103 // result will be returned as the input of |callback|. The version number of | 103 // result will be returned as the input of |callback|. The version number of |
| 104 // this interface pointer will also be updated. | 104 // this interface pointer will also be updated. |
| 105 void QueryVersion(const base::Callback<void(uint32_t)>& callback) { | 105 void QueryVersion(const base::Callback<void(uint32_t)>& callback) { |
| 106 internal_state_.QueryVersion(callback); | 106 internal_state_.QueryVersion(callback); |
| 107 } | 107 } |
| 108 | 108 |
| 109 // Returns a thread safe interface pointer that can be used to make interface |
| 110 // calls from any thread. The callbacks are invoked on the thread the |
| 111 // interface method is called from. |
| 112 scoped_refptr<ThreadSafeInterfacePtr<Interface>> GetThreadSafePtr() { |
| 113 return internal_state_.GetThreadSafePtr(); |
| 114 } |
| 115 |
| 109 // If the remote side doesn't support the specified version, it will close its | 116 // If the remote side doesn't support the specified version, it will close its |
| 110 // end of the message pipe asynchronously. This does nothing if it's already | 117 // end of the message pipe asynchronously. This does nothing if it's already |
| 111 // known that the remote side supports the specified version, i.e., if | 118 // known that the remote side supports the specified version, i.e., if |
| 112 // |version <= this->version()|. | 119 // |version <= this->version()|. |
| 113 // | 120 // |
| 114 // After calling RequireVersion() with a version not supported by the remote | 121 // After calling RequireVersion() with a version not supported by the remote |
| 115 // side, all subsequent calls to interface methods will be ignored. | 122 // side, all subsequent calls to interface methods will be ignored. |
| 116 void RequireVersion(uint32_t version) { | 123 void RequireVersion(uint32_t version) { |
| 117 internal_state_.RequireVersion(version); | 124 internal_state_.RequireVersion(version); |
| 118 } | 125 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 base::ThreadTaskRunnerHandle::Get()) { | 247 base::ThreadTaskRunnerHandle::Get()) { |
| 241 InterfacePtr<Interface> ptr; | 248 InterfacePtr<Interface> ptr; |
| 242 if (info.is_valid()) | 249 if (info.is_valid()) |
| 243 ptr.Bind(std::move(info), std::move(runner)); | 250 ptr.Bind(std::move(info), std::move(runner)); |
| 244 return std::move(ptr); | 251 return std::move(ptr); |
| 245 } | 252 } |
| 246 | 253 |
| 247 } // namespace mojo | 254 } // namespace mojo |
| 248 | 255 |
| 249 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_H_ | 256 #endif // MOJO_PUBLIC_CPP_BINDINGS_INTERFACE_PTR_H_ |
| OLD | NEW |