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 #ifndef CONTENT_PUBLIC_BROWSER_GLOBAL_REQUEST_ID_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_GLOBAL_REQUEST_ID_H_ |
6 #define CONTENT_PUBLIC_BROWSER_GLOBAL_REQUEST_ID_H_ | 6 #define CONTENT_PUBLIC_BROWSER_GLOBAL_REQUEST_ID_H_ |
7 | 7 |
| 8 #include <tuple> |
| 9 |
8 namespace content { | 10 namespace content { |
9 | 11 |
10 // Uniquely identifies a net::URLRequest. | 12 // Uniquely identifies a net::URLRequest. |
11 struct GlobalRequestID { | 13 struct GlobalRequestID { |
12 GlobalRequestID() : child_id(-1), request_id(-1) { | 14 GlobalRequestID() : child_id(-1), request_id(-1) { |
13 } | 15 } |
14 | 16 |
15 GlobalRequestID(int child_id, int request_id) | 17 GlobalRequestID(int child_id, int request_id) |
16 : child_id(child_id), | 18 : child_id(child_id), |
17 request_id(request_id) { | 19 request_id(request_id) { |
18 } | 20 } |
19 | 21 |
20 // The unique ID of the child process (different from OS's PID). | 22 // The unique ID of the child process (different from OS's PID). |
21 int child_id; | 23 int child_id; |
22 | 24 |
23 // The request ID (unique for the child). | 25 // The request ID (unique for the child). |
24 int request_id; | 26 int request_id; |
25 | 27 |
26 bool operator<(const GlobalRequestID& other) const { | 28 bool operator<(const GlobalRequestID& other) const { |
27 if (child_id == other.child_id) | 29 return std::tie(child_id, request_id) < |
28 return request_id < other.request_id; | 30 std::tie(other.child_id, other.request_id); |
29 return child_id < other.child_id; | |
30 } | 31 } |
31 bool operator==(const GlobalRequestID& other) const { | 32 bool operator==(const GlobalRequestID& other) const { |
32 return child_id == other.child_id && | 33 return child_id == other.child_id && |
33 request_id == other.request_id; | 34 request_id == other.request_id; |
34 } | 35 } |
35 bool operator!=(const GlobalRequestID& other) const { | 36 bool operator!=(const GlobalRequestID& other) const { |
36 return child_id != other.child_id || | 37 return child_id != other.child_id || |
37 request_id != other.request_id; | 38 request_id != other.request_id; |
38 } | 39 } |
39 }; | 40 }; |
40 | 41 |
41 } // namespace content | 42 } // namespace content |
42 | 43 |
43 #endif // CONTENT_PUBLIC_BROWSER_GLOBAL_REQUEST_ID_H_ | 44 #endif // CONTENT_PUBLIC_BROWSER_GLOBAL_REQUEST_ID_H_ |
OLD | NEW |