87835e0a788d1d9def14ffce92bec1419ffa6275
[platform/framework/web/crosswalk.git] / src / mojo / public / java / bindings / src / org / chromium / mojo / bindings / InterfaceRequest.java
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
3 // found in the LICENSE file.
4
5 package org.chromium.mojo.bindings;
6
7 import org.chromium.mojo.system.MessagePipeHandle;
8
9 /**
10  * One end of the message pipe representing a request to create an implementation to be bound to it.
11  * The other end of the pipe is bound to a proxy, which can be used immediately, while the
12  * InterfaceRequest is being sent.
13  * <p>
14  * InterfaceRequest are built using |Interface.Manager|.
15  *
16  * @param <P> the type of the remote interface proxy.
17  */
18 public class InterfaceRequest<P extends Interface> implements HandleOwner<MessagePipeHandle> {
19
20     /**
21      * The handle which will be sent and will be connected to the implementation.
22      */
23     private final MessagePipeHandle mHandle;
24
25     /**
26      * Constructor.
27      *
28      * @param handle the handle which will be sent and will be connected to the implementation.
29      */
30     InterfaceRequest(MessagePipeHandle handle) {
31         mHandle = handle;
32     }
33
34     /**
35      * @see HandleOwner#passHandle()
36      */
37     @Override
38     public MessagePipeHandle passHandle() {
39         return mHandle.pass();
40     }
41
42     /**
43      * @see java.io.Closeable#close()
44      */
45     @Override
46     public void close() {
47         mHandle.close();
48     }
49
50 }