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

Side by Side Diff: mojo/shell/public/cpp/shell_client.h

Issue 1691493002: Revise comments on various Shell interfaces. Make some methods private on ShellConnection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 10 months 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 | « mojo/shell/public/cpp/shell.h ('k') | mojo/shell/public/cpp/shell_connection.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 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_SHELL_PUBLIC_CPP_SHELL_CLIENT_H_ 5 #ifndef MOJO_SHELL_PUBLIC_CPP_SHELL_CLIENT_H_
6 #define MOJO_SHELL_PUBLIC_CPP_SHELL_CLIENT_H_ 6 #define MOJO_SHELL_PUBLIC_CPP_SHELL_CLIENT_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string> 9 #include <string>
10 10
11 #include "mojo/public/cpp/system/macros.h" 11 #include "mojo/public/cpp/system/macros.h"
12 #include "mojo/shell/public/cpp/connection.h" 12 #include "mojo/shell/public/cpp/connection.h"
13 13
14 namespace mojo { 14 namespace mojo {
15 15
16 class Shell; 16 class Shell;
17 17
18 // An abstract class that the application may subclass to control various 18 // An interface representing an instance "known to the Mojo Shell". The
19 // behaviors of ShellConnection. 19 // implementation receives lifecycle messages for the instance and gets the
20 // opportunity to handle inbound connections brokered by the Shell. Every client
21 // of ShellConnection must implement this interface, and instances of this
22 // interface must outlive the ShellConnection.
20 class ShellClient { 23 class ShellClient {
21 public: 24 public:
22 ShellClient(); 25 ShellClient();
23 virtual ~ShellClient(); 26 virtual ~ShellClient();
24 27
25 // Called once a bidirectional connection with the shell has been established. 28 // Called once a bidirectional connection with the shell has been established.
26 // |url| is the URL used to start the application. |id| is a unique identifier 29 // |url| is the URL used to start the application. |id| is a unique identifier
27 // the shell uses to identify this specific instance of the application. 30 // the shell uses to identify this specific instance of the application.
28 // Called exactly once before any other method. 31 // Called exactly once before any other method.
29 virtual void Initialize(Shell* shell, const std::string& url, uint32_t id); 32 virtual void Initialize(Shell* shell, const std::string& url, uint32_t id);
30 33
31 // Override this method to configure what services a connection supports when 34 // Called when a connection to this client is brokered by the shell. Override
32 // being connected to from an app. 35 // to expose services to the remote application. Return true if the connection
33 // Return false to reject the connection entirely. The default implementation 36 // should succeed. Return false if the connection should be rejected and the
34 // returns false. 37 // underlying pipe closed. The default implementation returns false.
35 virtual bool AcceptConnection(Connection* connection); 38 virtual bool AcceptConnection(Connection* connection);
36 39
37 // Called when the shell connection has a connection error. 40 // Called when ShellConnection's pipe to the Mojo Shell is closed.
38 // 41 //
39 // Return true to shutdown the application. Return false to skip shutting 42 // Returning true from this method will cause the ShellConnection instance to
40 // down the connection, but user is then required to call 43 // call this instance back via Quit(), and then run the termination closure
41 // ShellConnection::QuitNow() when done. Default implementation returns true. 44 // passed to it (which may do cleanup like, for example, quitting a run loop).
45 // Returning false from this method will not do any of this. The client is
46 // then responsible for calling Shell::QuitNow() when it is ready to close.
47 // The client may do this if it wishes to continue servicing connections other
48 // than the Shell.
49 // The default implementation returns true.
42 virtual bool ShellConnectionLost(); 50 virtual bool ShellConnectionLost();
43 51
44 // Called before ShellConnection::Terminate(). After returning from this call 52 // Called before ShellConnection::QuitNow(). After returning from this call
45 // the delegate can no longer rely on the main run loop still running. 53 // the delegate can no longer rely on the main run loop still running.
46 virtual void Quit(); 54 virtual void Quit();
47 55
48 private: 56 private:
49 MOJO_DISALLOW_COPY_AND_ASSIGN(ShellClient); 57 MOJO_DISALLOW_COPY_AND_ASSIGN(ShellClient);
50 }; 58 };
51 59
52 } // namespace mojo 60 } // namespace mojo
53 61
54 #endif // MOJO_SHELL_PUBLIC_CPP_SHELL_CLIENT_H_ 62 #endif // MOJO_SHELL_PUBLIC_CPP_SHELL_CLIENT_H_
OLDNEW
« no previous file with comments | « mojo/shell/public/cpp/shell.h ('k') | mojo/shell/public/cpp/shell_connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698