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

Side by Side Diff: mojo/public/cpp/bindings/connector.h

Issue 2623263005: Tag some of Mojo heap allocations for the heap profiler. (Closed)
Patch Set: Synced Created 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_PUBLIC_CPP_BINDINGS_CONNECTOR_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_CONNECTOR_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_CONNECTOR_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_CONNECTOR_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // callback. 143 // callback.
144 // It always returns false after CloseMessagePipe()/PassMessagePipe(). 144 // It always returns false after CloseMessagePipe()/PassMessagePipe().
145 bool during_sync_handle_watcher_callback() const { 145 bool during_sync_handle_watcher_callback() const {
146 return sync_handle_watcher_callback_count_ > 0; 146 return sync_handle_watcher_callback_count_ > 0;
147 } 147 }
148 148
149 base::SingleThreadTaskRunner* task_runner() const { 149 base::SingleThreadTaskRunner* task_runner() const {
150 return task_runner_.get(); 150 return task_runner_.get();
151 } 151 }
152 152
153 // Sets the tag used by the heap profiler.
154 // |tag| must be a const string literal.
155 void SetWatcherHeapProfilerTag(const char* tag);
156
153 private: 157 private:
154 // Callback of mojo::Watcher. 158 // Callback of mojo::Watcher.
155 void OnWatcherHandleReady(MojoResult result); 159 void OnWatcherHandleReady(MojoResult result);
156 // Callback of SyncHandleWatcher. 160 // Callback of SyncHandleWatcher.
157 void OnSyncHandleWatcherHandleReady(MojoResult result); 161 void OnSyncHandleWatcherHandleReady(MojoResult result);
158 void OnHandleReadyInternal(MojoResult result); 162 void OnHandleReadyInternal(MojoResult result);
159 163
160 void WaitToReadMore(); 164 void WaitToReadMore();
161 165
162 // Returns false if it is impossible to receive more messages in the future. 166 // Returns false if it is impossible to receive more messages in the future.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 bool allow_woken_up_by_others_ = false; 203 bool allow_woken_up_by_others_ = false;
200 // If non-zero, currently the control flow is inside the sync handle watcher 204 // If non-zero, currently the control flow is inside the sync handle watcher
201 // callback. 205 // callback.
202 size_t sync_handle_watcher_callback_count_ = 0; 206 size_t sync_handle_watcher_callback_count_ = 0;
203 207
204 base::ThreadChecker thread_checker_; 208 base::ThreadChecker thread_checker_;
205 209
206 base::Lock connected_lock_; 210 base::Lock connected_lock_;
207 bool connected_ = true; 211 bool connected_ = true;
208 212
213 // The tag used to track heap allocations that originated from a Watcher
214 // notification.
215 const char* heap_profiler_tag_ = nullptr;
216
209 // Create a single weak ptr and use it everywhere, to avoid the malloc/free 217 // Create a single weak ptr and use it everywhere, to avoid the malloc/free
210 // cost of creating a new weak ptr whenever it is needed. 218 // cost of creating a new weak ptr whenever it is needed.
211 // NOTE: This weak pointer is invalidated when the message pipe is closed or 219 // NOTE: This weak pointer is invalidated when the message pipe is closed or
212 // transferred (i.e., when |connected_| is set to false). 220 // transferred (i.e., when |connected_| is set to false).
213 base::WeakPtr<Connector> weak_self_; 221 base::WeakPtr<Connector> weak_self_;
214 base::WeakPtrFactory<Connector> weak_factory_; 222 base::WeakPtrFactory<Connector> weak_factory_;
215 223
216 DISALLOW_COPY_AND_ASSIGN(Connector); 224 DISALLOW_COPY_AND_ASSIGN(Connector);
217 }; 225 };
218 226
219 } // namespace mojo 227 } // namespace mojo
220 228
221 #endif // MOJO_PUBLIC_CPP_BINDINGS_CONNECTOR_H_ 229 #endif // MOJO_PUBLIC_CPP_BINDINGS_CONNECTOR_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/multiprocess_message_pipe_unittest.cc ('k') | mojo/public/cpp/bindings/lib/connector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698