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

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

Issue 1882423004: Move shell service to toplevel shell namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 | « services/shell/public/cpp/lib/shell_test.cc ('k') | services/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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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 SERVICES_SHELL_PUBLIC_CPP_MESSAGE_LOOP_REF_H_ 5 #ifndef SERVICES_SHELL_PUBLIC_CPP_MESSAGE_LOOP_REF_H_
6 #define SERVICES_SHELL_PUBLIC_CPP_MESSAGE_LOOP_REF_H_ 6 #define SERVICES_SHELL_PUBLIC_CPP_MESSAGE_LOOP_REF_H_
7 7
8 #include <memory>
9
8 #include "base/macros.h" 10 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
11 #include "mojo/public/cpp/system/core.h" 12 #include "mojo/public/cpp/system/core.h"
12 13
13 namespace mojo { 14 namespace shell {
14 15
15 class MessageLoopRefImpl; 16 class MessageLoopRefImpl;
16 17
17 // An interface implementation can keep this object as a member variable to 18 // 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 // hold a reference to the ShellConnection, keeping it alive as long as the
19 // bound implementation exists. 20 // bound implementation exists.
20 // Since interface implementations can be bound on different threads than the 21 // 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 // 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 // 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 // races between the AddRef resulting from cloning and destruction).
24 class MessageLoopRef { 25 class MessageLoopRef {
25 public: 26 public:
26 virtual ~MessageLoopRef() {} 27 virtual ~MessageLoopRef() {}
27 28
28 virtual scoped_ptr<MessageLoopRef> Clone() = 0; 29 virtual std::unique_ptr<MessageLoopRef> Clone() = 0;
29 }; 30 };
30 31
31 class MessageLoopRefFactory { 32 class MessageLoopRefFactory {
32 public: 33 public:
33 MessageLoopRefFactory(); 34 MessageLoopRefFactory();
34 ~MessageLoopRefFactory(); 35 ~MessageLoopRefFactory();
35 36
36 void set_quit_closure(const base::Closure& quit_closure) { 37 void set_quit_closure(const base::Closure& quit_closure) {
37 quit_closure_ = quit_closure; 38 quit_closure_ = quit_closure;
38 } 39 }
39 40
40 scoped_ptr<MessageLoopRef> CreateRef(); 41 std::unique_ptr<MessageLoopRef> CreateRef();
41 42
42 private: 43 private:
43 friend MessageLoopRefImpl; 44 friend MessageLoopRefImpl;
44 45
45 // Called from MessageLoopRefImpl. 46 // Called from MessageLoopRefImpl.
46 void AddRef(); 47 void AddRef();
47 void Release(); 48 void Release();
48 49
49 base::Closure quit_closure_; 50 base::Closure quit_closure_;
50 int ref_count_ = 0; 51 int ref_count_ = 0;
51 52
52 DISALLOW_COPY_AND_ASSIGN(MessageLoopRefFactory); 53 DISALLOW_COPY_AND_ASSIGN(MessageLoopRefFactory);
53 }; 54 };
54 55
55 } // namespace mojo 56 } // namespace shell
56 57
57 #endif // SERVICES_SHELL_PUBLIC_CPP_MESSAGE_LOOP_REF_H_ 58 #endif // SERVICES_SHELL_PUBLIC_CPP_MESSAGE_LOOP_REF_H_
OLDNEW
« no previous file with comments | « services/shell/public/cpp/lib/shell_test.cc ('k') | services/shell/public/cpp/names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698