OLD | NEW |
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 #include "extensions/test/extension_test_message_listener.h" | 5 #include "extensions/test/extension_test_message_listener.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "content/public/browser/notification_service.h" | 9 #include "content/public/browser/notification_service.h" |
10 #include "content/public/browser/notification_source.h" | 10 #include "content/public/browser/notification_source.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 content::RunMessageLoop(); | 48 content::RunMessageLoop(); |
49 return !failed_; | 49 return !failed_; |
50 } | 50 } |
51 | 51 |
52 void ExtensionTestMessageListener::Reply(const std::string& message) { | 52 void ExtensionTestMessageListener::Reply(const std::string& message) { |
53 CHECK(satisfied_); | 53 CHECK(satisfied_); |
54 CHECK(!replied_); | 54 CHECK(!replied_); |
55 | 55 |
56 replied_ = true; | 56 replied_ = true; |
57 function_->Reply(message); | 57 function_->Reply(message); |
58 function_ = NULL; | 58 function_ = nullptr; |
59 } | 59 } |
60 | 60 |
61 void ExtensionTestMessageListener::Reply(int message) { | 61 void ExtensionTestMessageListener::Reply(int message) { |
62 Reply(base::IntToString(message)); | 62 Reply(base::IntToString(message)); |
63 } | 63 } |
64 | 64 |
65 void ExtensionTestMessageListener::ReplyWithError(const std::string& error) { | 65 void ExtensionTestMessageListener::ReplyWithError(const std::string& error) { |
66 CHECK(satisfied_); | 66 CHECK(satisfied_); |
67 CHECK(!replied_); | 67 CHECK(!replied_); |
68 | 68 |
69 replied_ = true; | 69 replied_ = true; |
70 function_->ReplyWithError(error); | 70 function_->ReplyWithError(error); |
71 function_ = NULL; | 71 function_ = nullptr; |
72 } | 72 } |
73 | 73 |
74 void ExtensionTestMessageListener::Reset() { | 74 void ExtensionTestMessageListener::Reset() { |
75 satisfied_ = false; | 75 satisfied_ = false; |
76 failed_ = false; | 76 failed_ = false; |
77 message_.clear(); | 77 message_.clear(); |
78 replied_ = false; | 78 replied_ = false; |
79 } | 79 } |
80 | 80 |
81 void ExtensionTestMessageListener::Observe( | 81 void ExtensionTestMessageListener::Observe( |
(...skipping 25 matching lines...) Expand all Loading... |
107 function_ = function; | 107 function_ = function; |
108 if (!will_reply_) | 108 if (!will_reply_) |
109 Reply(std::string()); | 109 Reply(std::string()); |
110 | 110 |
111 if (waiting_) { | 111 if (waiting_) { |
112 waiting_ = false; | 112 waiting_ = false; |
113 base::MessageLoopForUI::current()->Quit(); | 113 base::MessageLoopForUI::current()->Quit(); |
114 } | 114 } |
115 } | 115 } |
116 } | 116 } |
OLD | NEW |