OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <set> | 5 #include <set> |
| 6 #include <tuple> |
6 | 7 |
7 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
8 #include "base/pickle.h" | 9 #include "base/pickle.h" |
9 #include "base/values.h" | 10 #include "base/values.h" |
10 #include "extensions/common/api/sockets/sockets_manifest_permission.h" | 11 #include "extensions/common/api/sockets/sockets_manifest_permission.h" |
11 #include "extensions/common/manifest_constants.h" | 12 #include "extensions/common/manifest_constants.h" |
12 #include "ipc/ipc_message.h" | 13 #include "ipc/ipc_message.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
15 using content::SocketPermissionRequest; | 16 using content::SocketPermissionRequest; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 } | 61 } |
61 | 62 |
62 struct CheckFormatEntry { | 63 struct CheckFormatEntry { |
63 CheckFormatEntry(SocketPermissionRequest::OperationType operation_type, | 64 CheckFormatEntry(SocketPermissionRequest::OperationType operation_type, |
64 std::string host_pattern) | 65 std::string host_pattern) |
65 : operation_type(operation_type), host_pattern(host_pattern) {} | 66 : operation_type(operation_type), host_pattern(host_pattern) {} |
66 | 67 |
67 // operators <, == are needed by container std::set and algorithms | 68 // operators <, == are needed by container std::set and algorithms |
68 // std::set_includes and std::set_differences. | 69 // std::set_includes and std::set_differences. |
69 bool operator<(const CheckFormatEntry& rhs) const { | 70 bool operator<(const CheckFormatEntry& rhs) const { |
70 if (operation_type == rhs.operation_type) | 71 return std::tie(operation_type, host_pattern) < |
71 return host_pattern < rhs.host_pattern; | 72 std::tie(rhs.operation_type, rhs.host_pattern); |
72 | |
73 return operation_type < rhs.operation_type; | |
74 } | 73 } |
75 | 74 |
76 bool operator==(const CheckFormatEntry& rhs) const { | 75 bool operator==(const CheckFormatEntry& rhs) const { |
77 return operation_type == rhs.operation_type && | 76 return operation_type == rhs.operation_type && |
78 host_pattern == rhs.host_pattern; | 77 host_pattern == rhs.host_pattern; |
79 } | 78 } |
80 | 79 |
81 SocketPermissionRequest::OperationType operation_type; | 80 SocketPermissionRequest::OperationType operation_type; |
82 std::string host_pattern; | 81 std::string host_pattern; |
83 }; | 82 }; |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 new SocketsManifestPermission()); | 397 new SocketsManifestPermission()); |
399 | 398 |
400 IPC::Message m; | 399 IPC::Message m; |
401 ipc_perm->Write(&m); | 400 ipc_perm->Write(&m); |
402 base::PickleIterator iter(m); | 401 base::PickleIterator iter(m); |
403 EXPECT_TRUE(ipc_perm2->Read(&m, &iter)); | 402 EXPECT_TRUE(ipc_perm2->Read(&m, &iter)); |
404 EXPECT_TRUE(permission->Equal(ipc_perm2.get())); | 403 EXPECT_TRUE(permission->Equal(ipc_perm2.get())); |
405 } | 404 } |
406 | 405 |
407 } // namespace extensions | 406 } // namespace extensions |
OLD | NEW |