 Chromium Code Reviews
 Chromium Code Reviews Issue 13533007:
  Test extension reloading behavior.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 13533007:
  Test extension reloading behavior.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 IPC_IPC_TEST_SINK_H_ | 5 #ifndef IPC_IPC_TEST_SINK_H_ | 
| 6 #define IPC_IPC_TEST_SINK_H_ | 6 #define IPC_IPC_TEST_SINK_H_ | 
| 7 | 7 | 
| 8 #include <utility> | 8 #include <utility> | 
| 9 #include <vector> | 9 #include <vector> | 
| 10 | 10 | 
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" | 
| 12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" | 
| 13 #include "ipc/ipc_channel.h" | 13 #include "ipc/ipc_channel.h" | 
| 14 #include "ipc/ipc_listener.h" | |
| 14 | 15 | 
| 15 namespace IPC { | 16 namespace IPC { | 
| 16 | 17 | 
| 17 class Message; | 18 class Message; | 
| 18 | 19 | 
| 19 // This test sink provides a "sink" for IPC messages that are sent. It allows | 20 // This test sink provides a "sink" for IPC messages that are sent. It allows | 
| 20 // the caller to query messages received in various different ways. It is | 21 // the caller to query messages received in various different ways. It is | 
| 21 // designed for tests for objects that use the IPC system. | 22 // designed for tests for objects that use the IPC system. | 
| 22 // | 23 // | 
| 23 // Typical usage: | 24 // Typical usage: | 
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 // | 64 // | 
| 64 // MyListener listener; | 65 // MyListener listener; | 
| 65 // test_sink.AddFilter(&listener); | 66 // test_sink.AddFilter(&listener); | 
| 66 // StartSomeAsynchronousProcess(&test_sink); | 67 // StartSomeAsynchronousProcess(&test_sink); | 
| 67 // MessageLoop::current()->Run(); | 68 // MessageLoop::current()->Run(); | 
| 68 // <inspect the results> | 69 // <inspect the results> | 
| 69 // ... | 70 // ... | 
| 70 // | 71 // | 
| 71 // To hook up the sink, all you need to do is call OnMessageReceived when a | 72 // To hook up the sink, all you need to do is call OnMessageReceived when a | 
| 72 // message is received. | 73 // message is received. | 
| 73 class TestSink : public Channel { | 74 class TestSink : public Channel, public Listener { | 
| 
Jeffrey Yasskin
2013/04/04 09:34:35
This allows chaining TestSinks.
 | |
| 74 public: | 75 public: | 
| 75 TestSink(); | 76 TestSink(); | 
| 76 virtual ~TestSink(); | 77 virtual ~TestSink(); | 
| 77 | 78 | 
| 78 // Interface in IPC::Channel. This copies the message to the sink and then | 79 // Interface in IPC::Channel. This copies the message to the sink and then | 
| 79 // deletes it. | 80 // deletes it. | 
| 80 virtual bool Send(IPC::Message* message) OVERRIDE; | 81 virtual bool Send(IPC::Message* message) OVERRIDE; | 
| 81 | 82 | 
| 82 // Used by the source of the messages to send the message to the sink. This | 83 // Used by the source of the messages to send the message to the sink. This | 
| 83 // will make a copy of the message and store it in the list. | 84 // will make a copy of the message and store it in the list. | 
| 84 bool OnMessageReceived(const Message& msg); | 85 virtual bool OnMessageReceived(const Message& msg) OVERRIDE; | 
| 85 | 86 | 
| 86 // Returns the number of messages in the queue. | 87 // Returns the number of messages in the queue. | 
| 87 size_t message_count() const { return messages_.size(); } | 88 size_t message_count() const { return messages_.size(); } | 
| 88 | 89 | 
| 89 // Clears the message queue of saved messages. | 90 // Clears the message queue of saved messages. | 
| 90 void ClearMessages(); | 91 void ClearMessages(); | 
| 91 | 92 | 
| 92 // Returns the message at the given index in the queue. The index may be out | 93 // Returns the message at the given index in the queue. The index may be out | 
| 93 // of range, in which case the return value is NULL. The returned pointer will | 94 // of range, in which case the return value is NULL. The returned pointer will | 
| 94 // only be valid until another message is received or the list is cleared. | 95 // only be valid until another message is received or the list is cleared. | 
| (...skipping 25 matching lines...) Expand all Loading... | |
| 120 // The actual list of received messages. | 121 // The actual list of received messages. | 
| 121 std::vector<Message> messages_; | 122 std::vector<Message> messages_; | 
| 122 ObserverList<Listener> filter_list_; | 123 ObserverList<Listener> filter_list_; | 
| 123 | 124 | 
| 124 DISALLOW_COPY_AND_ASSIGN(TestSink); | 125 DISALLOW_COPY_AND_ASSIGN(TestSink); | 
| 125 }; | 126 }; | 
| 126 | 127 | 
| 127 } // namespace IPC | 128 } // namespace IPC | 
| 128 | 129 | 
| 129 #endif // IPC_IPC_TEST_SINK_H_ | 130 #endif // IPC_IPC_TEST_SINK_H_ | 
| OLD | NEW |