| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 NET_SPDY_SPDY_SESSION_TEST_UTIL_H_ | 5 #ifndef NET_SPDY_SPDY_SESSION_TEST_UTIL_H_ |
| 6 #define NET_SPDY_SPDY_SESSION_TEST_UTIL_H_ | 6 #define NET_SPDY_SPDY_SESSION_TEST_UTIL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | |
| 11 | |
| 12 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 13 #include "base/pending_task.h" | 11 #include "base/pending_task.h" |
| 12 #include "net/spdy/platform/api/spdy_string.h" |
| 14 | 13 |
| 15 namespace net { | 14 namespace net { |
| 16 | 15 |
| 17 // SpdySessionTestTaskObserver is a MessageLoop::TaskObserver that monitors the | 16 // SpdySessionTestTaskObserver is a MessageLoop::TaskObserver that monitors the |
| 18 // completion of all tasks executed by the current MessageLoop, recording the | 17 // completion of all tasks executed by the current MessageLoop, recording the |
| 19 // number of tasks that refer to a specific function and filename. | 18 // number of tasks that refer to a specific function and filename. |
| 20 class SpdySessionTestTaskObserver : public base::MessageLoop::TaskObserver { | 19 class SpdySessionTestTaskObserver : public base::MessageLoop::TaskObserver { |
| 21 public: | 20 public: |
| 22 // Creates a SpdySessionTaskObserver that will record all tasks that are | 21 // Creates a SpdySessionTaskObserver that will record all tasks that are |
| 23 // executed that were posted by the function named by |function_name|, located | 22 // executed that were posted by the function named by |function_name|, located |
| 24 // in the file |file_name|. | 23 // in the file |file_name|. |
| 25 // Example: | 24 // Example: |
| 26 // file_name = "foo.cc" | 25 // file_name = "foo.cc" |
| 27 // function = "DoFoo" | 26 // function = "DoFoo" |
| 28 SpdySessionTestTaskObserver(const std::string& file_name, | 27 SpdySessionTestTaskObserver(const SpdyString& file_name, |
| 29 const std::string& function_name); | 28 const SpdyString& function_name); |
| 30 ~SpdySessionTestTaskObserver() override; | 29 ~SpdySessionTestTaskObserver() override; |
| 31 | 30 |
| 32 // Implements MessageLoop::TaskObserver. | 31 // Implements MessageLoop::TaskObserver. |
| 33 void WillProcessTask(const base::PendingTask& pending_task) override; | 32 void WillProcessTask(const base::PendingTask& pending_task) override; |
| 34 void DidProcessTask(const base::PendingTask& pending_task) override; | 33 void DidProcessTask(const base::PendingTask& pending_task) override; |
| 35 | 34 |
| 36 // Returns the number of tasks posted by the given function and file. | 35 // Returns the number of tasks posted by the given function and file. |
| 37 uint16_t executed_count() const { return executed_count_; } | 36 uint16_t executed_count() const { return executed_count_; } |
| 38 | 37 |
| 39 private: | 38 private: |
| 40 uint16_t executed_count_; | 39 uint16_t executed_count_; |
| 41 std::string file_name_; | 40 SpdyString file_name_; |
| 42 std::string function_name_; | 41 SpdyString function_name_; |
| 43 }; | 42 }; |
| 44 | 43 |
| 45 } // namespace net | 44 } // namespace net |
| 46 | 45 |
| 47 #endif // NET_SPDY_SPDY_SESSION_TEST_UTIL_H_ | 46 #endif // NET_SPDY_SPDY_SESSION_TEST_UTIL_H_ |
| OLD | NEW |