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

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

Issue 1877753003: Move mojo\shell to services\shell (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@62scan
Patch Set: . Created 4 years, 8 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/lib/shell_test.cc ('k') | mojo/shell/public/cpp/names.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MOJO_SHELL_PUBLIC_CPP_MESSAGE_LOOP_REF_H_
6 #define MOJO_SHELL_PUBLIC_CPP_MESSAGE_LOOP_REF_H_
7
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h"
11 #include "mojo/public/cpp/system/core.h"
12
13 namespace mojo {
14
15 class MessageLoopRefImpl;
16
17 // An interface implementation can keep this object as a member variable to
18 // hold a reference to the ShellConnection, keeping it alive as long as the
19 // bound implementation exists.
20 // Since interface implementations can be bound on different threads than the
21 // ShellConnection, this class is safe to use on any thread. However, each
22 // instance should only be used on one thread at a time (otherwise there'll be
23 // races between the AddRef resulting from cloning and destruction).
24 class MessageLoopRef {
25 public:
26 virtual ~MessageLoopRef() {}
27
28 virtual scoped_ptr<MessageLoopRef> Clone() = 0;
29 };
30
31 class MessageLoopRefFactory {
32 public:
33 MessageLoopRefFactory();
34 ~MessageLoopRefFactory();
35
36 void set_quit_closure(const base::Closure& quit_closure) {
37 quit_closure_ = quit_closure;
38 }
39
40 scoped_ptr<MessageLoopRef> CreateRef();
41
42 private:
43 friend MessageLoopRefImpl;
44
45 // Called from MessageLoopRefImpl.
46 void AddRef();
47 void Release();
48
49 base::Closure quit_closure_;
50 int ref_count_ = 0;
51
52 DISALLOW_COPY_AND_ASSIGN(MessageLoopRefFactory);
53 };
54
55 } // namespace mojo
56
57 #endif // MOJO_SHELL_PUBLIC_CPP_MESSAGE_LOOP_REF_H_
OLDNEW
« no previous file with comments | « mojo/shell/public/cpp/lib/shell_test.cc ('k') | mojo/shell/public/cpp/names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698