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 <queue> | 5 #include <queue> |
6 #include <map> | 6 #include <map> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 template <typename Collection, typename Key> | 70 template <typename Collection, typename Key> |
71 bool Contains(const Collection& collection, const Key& key) { | 71 bool Contains(const Collection& collection, const Key& key) { |
72 return std::find(collection.begin(), collection.end(), key) != | 72 return std::find(collection.begin(), collection.end(), key) != |
73 collection.end(); | 73 collection.end(); |
74 } | 74 } |
75 | 75 |
76 } // namespace | 76 } // namespace |
77 | 77 |
78 // A mock event router that responds to events with a pre-arranged queue of | 78 // A mock event router that responds to events with a pre-arranged queue of |
79 // Tasks. | 79 // Tasks. |
80 class TestIPCSender : public IPC::Message::Sender { | 80 class TestIPCSender : public IPC::Sender { |
81 public: | 81 public: |
82 typedef std::list<linked_ptr<IPC::Message> > SentMessages; | 82 typedef std::list<linked_ptr<IPC::Message> > SentMessages; |
83 | 83 |
84 // Adds a Task to the queue. We will fire these in order as events are | 84 // Adds a Task to the queue. We will fire these in order as events are |
85 // dispatched. | 85 // dispatched. |
86 void PushTask(const base::Closure& task) { | 86 void PushTask(const base::Closure& task) { |
87 task_queue_.push(task); | 87 task_queue_.push(task); |
88 } | 88 } |
89 | 89 |
90 size_t GetNumTasks() { return task_queue_.size(); } | 90 size_t GetNumTasks() { return task_queue_.size(); } |
91 | 91 |
92 SentMessages::const_iterator sent_begin() const { | 92 SentMessages::const_iterator sent_begin() const { |
93 return sent_messages_.begin(); | 93 return sent_messages_.begin(); |
94 } | 94 } |
95 | 95 |
96 SentMessages::const_iterator sent_end() const { | 96 SentMessages::const_iterator sent_end() const { |
97 return sent_messages_.end(); | 97 return sent_messages_.end(); |
98 } | 98 } |
99 | 99 |
100 private: | 100 private: |
101 // IPC::Message::Sender | 101 // IPC::Sender |
102 virtual bool Send(IPC::Message* message) { | 102 virtual bool Send(IPC::Message* message) { |
103 EXPECT_EQ(ExtensionMsg_MessageInvoke::ID, message->type()); | 103 EXPECT_EQ(ExtensionMsg_MessageInvoke::ID, message->type()); |
104 | 104 |
105 EXPECT_FALSE(task_queue_.empty()); | 105 EXPECT_FALSE(task_queue_.empty()); |
106 MessageLoop::current()->PostTask(FROM_HERE, task_queue_.front()); | 106 MessageLoop::current()->PostTask(FROM_HERE, task_queue_.front()); |
107 task_queue_.pop(); | 107 task_queue_.pop(); |
108 | 108 |
109 sent_messages_.push_back(linked_ptr<IPC::Message>(message)); | 109 sent_messages_.push_back(linked_ptr<IPC::Message>(message)); |
110 return true; | 110 return true; |
111 } | 111 } |
(...skipping 1395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1507 }; | 1507 }; |
1508 for (size_t i = 0; i < arraysize(sensitive_urls); ++i) { | 1508 for (size_t i = 0; i < arraysize(sensitive_urls); ++i) { |
1509 EXPECT_TRUE(helpers::HideRequestForURL(GURL(sensitive_urls[i]))) | 1509 EXPECT_TRUE(helpers::HideRequestForURL(GURL(sensitive_urls[i]))) |
1510 << sensitive_urls[i]; | 1510 << sensitive_urls[i]; |
1511 } | 1511 } |
1512 for (size_t i = 0; i < arraysize(non_sensitive_urls); ++i) { | 1512 for (size_t i = 0; i < arraysize(non_sensitive_urls); ++i) { |
1513 EXPECT_FALSE(helpers::HideRequestForURL(GURL(non_sensitive_urls[i]))) | 1513 EXPECT_FALSE(helpers::HideRequestForURL(GURL(non_sensitive_urls[i]))) |
1514 << non_sensitive_urls[i]; | 1514 << non_sensitive_urls[i]; |
1515 } | 1515 } |
1516 } | 1516 } |
OLD | NEW |