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

Side by Side Diff: content/common/child_process_host_impl.h

Issue 126033004: Clean up ChildProcessHost unique id generation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: start from 1 Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CONTENT_COMMON_CHILD_PROCESS_HOST_IMPL_H_ 5 #ifndef CONTENT_COMMON_CHILD_PROCESS_HOST_IMPL_H_
6 #define CONTENT_COMMON_CHILD_PROCESS_HOST_IMPL_H_ 6 #define CONTENT_COMMON_CHILD_PROCESS_HOST_IMPL_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 19 matching lines...) Expand all
30 class ChildProcessHostDelegate; 30 class ChildProcessHostDelegate;
31 31
32 // Provides common functionality for hosting a child process and processing IPC 32 // Provides common functionality for hosting a child process and processing IPC
33 // messages between the host and the child process. Users are responsible 33 // messages between the host and the child process. Users are responsible
34 // for the actual launching and terminating of the child processes. 34 // for the actual launching and terminating of the child processes.
35 class CONTENT_EXPORT ChildProcessHostImpl : public ChildProcessHost, 35 class CONTENT_EXPORT ChildProcessHostImpl : public ChildProcessHost,
36 public IPC::Listener { 36 public IPC::Listener {
37 public: 37 public:
38 virtual ~ChildProcessHostImpl(); 38 virtual ~ChildProcessHostImpl();
39 39
40 // This value is guaranteed to never be returned by
41 // GenerateChildProcessUniqueId() below.
42 static int kInvalidChildProcessId;
43
44 // Public and static for reuse by RenderMessageFilter. 40 // Public and static for reuse by RenderMessageFilter.
45 static void AllocateSharedMemory( 41 static void AllocateSharedMemory(
46 size_t buffer_size, base::ProcessHandle child_process, 42 size_t buffer_size, base::ProcessHandle child_process,
47 base::SharedMemoryHandle* handle); 43 base::SharedMemoryHandle* handle);
48 44
49 // Returns a unique ID to identify a child process. On construction, this 45 // Returns a unique ID to identify a child process. On construction, this
50 // function will be used to generate the id_, but it is also used to generate 46 // function will be used to generate the id_, but it is also used to generate
51 // IDs for the RenderProcessHost, which doesn't inherit from us, and whose IDs 47 // IDs for the RenderProcessHost, which doesn't inherit from us, and whose IDs
52 // must be unique for all child processes. 48 // must be unique for all child processes.
53 // 49 //
54 // This function is threadsafe since RenderProcessHost is on the UI thread, 50 // This function is threadsafe since RenderProcessHost is on the UI thread,
55 // but normally this will be used on the IO thread. 51 // but normally this will be used on the IO thread.
52 //
53 // This will never return ChildProcessHost::kInvalidChildProcessUniqueId.
56 static int GenerateChildProcessUniqueId(); 54 static int GenerateChildProcessUniqueId();
57 55
58 // ChildProcessHost implementation 56 // ChildProcessHost implementation
59 virtual bool Send(IPC::Message* message) OVERRIDE; 57 virtual bool Send(IPC::Message* message) OVERRIDE;
60 virtual void ForceShutdown() OVERRIDE; 58 virtual void ForceShutdown() OVERRIDE;
61 virtual std::string CreateChannel() OVERRIDE; 59 virtual std::string CreateChannel() OVERRIDE;
62 virtual bool IsChannelOpening() OVERRIDE; 60 virtual bool IsChannelOpening() OVERRIDE;
63 virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter) OVERRIDE; 61 virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter) OVERRIDE;
64 #if defined(OS_POSIX) 62 #if defined(OS_POSIX)
65 virtual int TakeClientFileDescriptor() OVERRIDE; 63 virtual int TakeClientFileDescriptor() OVERRIDE;
(...skipping 28 matching lines...) Expand all
94 // thread, we don't have a IPC::ChannelProxy and so we manage filters 92 // thread, we don't have a IPC::ChannelProxy and so we manage filters
95 // manually. 93 // manually.
96 std::vector<scoped_refptr<IPC::ChannelProxy::MessageFilter> > filters_; 94 std::vector<scoped_refptr<IPC::ChannelProxy::MessageFilter> > filters_;
97 95
98 DISALLOW_COPY_AND_ASSIGN(ChildProcessHostImpl); 96 DISALLOW_COPY_AND_ASSIGN(ChildProcessHostImpl);
99 }; 97 };
100 98
101 } // namespace content 99 } // namespace content
102 100
103 #endif // CONTENT_COMMON_CHILD_PROCESS_HOST_IMPL_H_ 101 #endif // CONTENT_COMMON_CHILD_PROCESS_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698