Fix emulator build error
[platform/framework/web/chromium-efl.git] / components / permissions / permission_request_id.h
1 // Copyright 2015 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_PERMISSIONS_PERMISSION_REQUEST_ID_H_
6 #define COMPONENTS_PERMISSIONS_PERMISSION_REQUEST_ID_H_
7
8 #include <string>
9
10 #include "base/types/id_type.h"
11 #include "content/public/browser/global_routing_id.h"
12 #include "url/gurl.h"
13
14 namespace content {
15 class RenderFrameHost;
16 }  // namespace content
17
18 namespace permissions {
19
20 // Uniquely identifies a particular permission request.
21 // None of the different attributes (render_process_id, render_frame_id or
22 // request_local_id) is enough to compare two requests. In order to check if
23 // a request is the same as another one, consumers of this class should use
24 // the operator== or operator!=.
25 class PermissionRequestID {
26  public:
27   // Uniquely identifies a request (at least) within a given frame.
28   using RequestLocalId = base::IdType64<PermissionRequestID>;
29
30   PermissionRequestID(content::RenderFrameHost* render_frame_host,
31                       RequestLocalId request_local_id);
32   PermissionRequestID(content::GlobalRenderFrameHostId id,
33                       RequestLocalId request_local_id);
34   ~PermissionRequestID();
35
36   PermissionRequestID(const PermissionRequestID&);
37   PermissionRequestID& operator=(const PermissionRequestID&);
38
39   void set_global_render_frame_host_id(
40       const content::GlobalRenderFrameHostId& id) {
41     global_render_frame_host_id_ = id;
42   }
43
44   const content::GlobalRenderFrameHostId& global_render_frame_host_id() const {
45     return global_render_frame_host_id_;
46   }
47
48   // Deprecated. Only accessible for testing.
49   RequestLocalId request_local_id_for_testing() const {
50     return request_local_id_;
51   }
52
53   bool operator==(const PermissionRequestID& other) const;
54   bool operator!=(const PermissionRequestID& other) const;
55
56   std::string ToString() const;
57
58  private:
59   content::GlobalRenderFrameHostId global_render_frame_host_id_;
60   RequestLocalId request_local_id_;
61 };
62
63 }  // namespace permissions
64
65 namespace std {
66 template <>
67 struct hash<permissions::PermissionRequestID::RequestLocalId>
68     : public permissions::PermissionRequestID::RequestLocalId::Hasher {};
69 }  // namespace std
70
71 #endif  // COMPONENTS_PERMISSIONS_PERMISSION_REQUEST_ID_H_