| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "services/tracing/tracing_app.h" | 5 #include "services/tracing/tracing_app.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 | 10 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 [](TraceProvider* controller) { controller->StopTracing(); }); | 74 [](TraceProvider* controller) { controller->StopTracing(); }); |
| 75 | 75 |
| 76 // Sending the StopTracing message to registered controllers will request that | 76 // Sending the StopTracing message to registered controllers will request that |
| 77 // they send trace data back via the collector interface and, when they are | 77 // they send trace data back via the collector interface and, when they are |
| 78 // done, close the collector pipe. We don't know how long they will take. We | 78 // done, close the collector pipe. We don't know how long they will take. We |
| 79 // want to read all data that any collector might send until all collectors or | 79 // want to read all data that any collector might send until all collectors or |
| 80 // closed or an (arbitrary) deadline has passed. Since the bindings don't | 80 // closed or an (arbitrary) deadline has passed. Since the bindings don't |
| 81 // support this directly we do our own MojoWaitMany over the handles and read | 81 // support this directly we do our own MojoWaitMany over the handles and read |
| 82 // individual messages until all are closed or our absolute deadline has | 82 // individual messages until all are closed or our absolute deadline has |
| 83 // elapsed. | 83 // elapsed. |
| 84 static const MojoDeadline kTimeToWaitMicros = 5000 * 1000; | 84 static const MojoDeadline kTimeToWaitMicros = 5 * 1000000; |
| 85 MojoTimeTicks end = MojoGetTimeTicksNow() + kTimeToWaitMicros; | 85 MojoTimeTicks end = MojoGetTimeTicksNow() + kTimeToWaitMicros; |
| 86 | 86 |
| 87 while (!recorder_impls_.empty()) { | 87 while (!recorder_impls_.empty()) { |
| 88 MojoTimeTicks now = MojoGetTimeTicksNow(); | 88 MojoTimeTicks now = MojoGetTimeTicksNow(); |
| 89 if (now >= end) // Timed out? | 89 if (now >= end) // Timed out? |
| 90 break; | 90 break; |
| 91 | 91 |
| 92 MojoDeadline mojo_deadline = end - now; | 92 MojoDeadline mojo_deadline = end - now; |
| 93 std::vector<mojo::Handle> handles; | 93 std::vector<mojo::Handle> handles; |
| 94 std::vector<MojoHandleSignals> signals; | 94 std::vector<MojoHandleSignals> signals; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 124 } | 124 } |
| 125 AllDataCollected(); | 125 AllDataCollected(); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void TracingApp::AllDataCollected() { | 128 void TracingApp::AllDataCollected() { |
| 129 recorder_impls_.clear(); | 129 recorder_impls_.clear(); |
| 130 sink_.reset(); | 130 sink_.reset(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 } // namespace tracing | 133 } // namespace tracing |
| OLD | NEW |