Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: extensions/browser/api/web_request/web_request_event_details.h

Issue 1902873002: Convert //extensions/browser/api from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_EVENT_DETAILS_H_ 5 #ifndef EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_EVENT_DETAILS_H_
6 #define EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_EVENT_DETAILS_H_ 6 #define EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_EVENT_DETAILS_H_
7 7
8 #include <memory>
8 #include <string> 9 #include <string>
9 10
10 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "extensions/browser/extension_api_frame_id_map.h" 14 #include "extensions/browser/extension_api_frame_id_map.h"
15 15
16 namespace net { 16 namespace net {
17 class AuthChallengeInfo; 17 class AuthChallengeInfo;
18 class HttpRequestHeaders; 18 class HttpRequestHeaders;
19 class HttpResponseHeaders; 19 class HttpResponseHeaders;
20 class URLRequest; 20 class URLRequest;
21 } 21 }
22 22
23 namespace extensions { 23 namespace extensions {
24 24
25 // This helper class is used to construct the details for a webRequest event 25 // This helper class is used to construct the details for a webRequest event
26 // dictionary. Some keys are present on every event, others are only relevant 26 // dictionary. Some keys are present on every event, others are only relevant
27 // for a few events. And some keys must only be added to the event details if 27 // for a few events. And some keys must only be added to the event details if
28 // requested at the registration of the event listener (in ExtraInfoSpec). 28 // requested at the registration of the event listener (in ExtraInfoSpec).
29 // This class provides setters that are aware of these rules. 29 // This class provides setters that are aware of these rules.
30 // 30 //
31 // Not all keys are managed by this class. Keys that do not require a special 31 // Not all keys are managed by this class. Keys that do not require a special
32 // treatment can be set using the generic SetBoolean / SetInteger / SetString 32 // treatment can be set using the generic SetBoolean / SetInteger / SetString
33 // methods (e.g. to set "error", "message", "redirectUrl", "stage" or "tabId"). 33 // methods (e.g. to set "error", "message", "redirectUrl", "stage" or "tabId").
34 // 34 //
35 // This class should be constructed on the IO thread. It can safely be used on 35 // This class should be constructed on the IO thread. It can safely be used on
36 // other threads, as long as there is no concurrent access. 36 // other threads, as long as there is no concurrent access.
37 class WebRequestEventDetails { 37 class WebRequestEventDetails {
38 public: 38 public:
39 using DeterminedFrameIdCallback = 39 using DeterminedFrameIdCallback =
40 base::Callback<void(scoped_ptr<WebRequestEventDetails>)>; 40 base::Callback<void(std::unique_ptr<WebRequestEventDetails>)>;
41 41
42 // Create a WebRequestEventDetails with the following keys: 42 // Create a WebRequestEventDetails with the following keys:
43 // - method 43 // - method
44 // - requestId 44 // - requestId
45 // - tabId 45 // - tabId
46 // - timeStamp 46 // - timeStamp
47 // - type 47 // - type
48 // - url 48 // - url
49 WebRequestEventDetails(const net::URLRequest* request, int extra_info_spec); 49 WebRequestEventDetails(const net::URLRequest* request, int extra_info_spec);
50 ~WebRequestEventDetails(); 50 ~WebRequestEventDetails();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // synchronous or asynchronous. 104 // synchronous or asynchronous.
105 // 105 //
106 // The caller must not use or delete this WebRequestEventDetails instance 106 // The caller must not use or delete this WebRequestEventDetails instance
107 // after calling this method. Ownership of this instance is transferred to 107 // after calling this method. Ownership of this instance is transferred to
108 // |callback|. 108 // |callback|.
109 void DetermineFrameIdOnIO(const DeterminedFrameIdCallback& callback); 109 void DetermineFrameIdOnIO(const DeterminedFrameIdCallback& callback);
110 110
111 // Create an event dictionary that contains all required keys, and also the 111 // Create an event dictionary that contains all required keys, and also the
112 // extra keys as specified by the |extra_info_spec| filter. 112 // extra keys as specified by the |extra_info_spec| filter.
113 // This can be called from any thread. 113 // This can be called from any thread.
114 scoped_ptr<base::DictionaryValue> GetFilteredDict(int extra_info_spec) const; 114 std::unique_ptr<base::DictionaryValue> GetFilteredDict(
115 int extra_info_spec) const;
115 116
116 // Get the internal dictionary, unfiltered. After this call, the internal 117 // Get the internal dictionary, unfiltered. After this call, the internal
117 // dictionary is empty. 118 // dictionary is empty.
118 scoped_ptr<base::DictionaryValue> GetAndClearDict(); 119 std::unique_ptr<base::DictionaryValue> GetAndClearDict();
119 120
120 private: 121 private:
121 void OnDeterminedFrameId(scoped_ptr<WebRequestEventDetails> self, 122 void OnDeterminedFrameId(std::unique_ptr<WebRequestEventDetails> self,
122 const DeterminedFrameIdCallback& callback, 123 const DeterminedFrameIdCallback& callback,
123 const ExtensionApiFrameIdMap::FrameData& frame_data); 124 const ExtensionApiFrameIdMap::FrameData& frame_data);
124 125
125 // The details that are always included in a webRequest event object. 126 // The details that are always included in a webRequest event object.
126 base::DictionaryValue dict_; 127 base::DictionaryValue dict_;
127 128
128 // Extra event details: Only included when |extra_info_spec_| matches. 129 // Extra event details: Only included when |extra_info_spec_| matches.
129 scoped_ptr<base::DictionaryValue> request_body_; 130 std::unique_ptr<base::DictionaryValue> request_body_;
130 scoped_ptr<base::ListValue> request_headers_; 131 std::unique_ptr<base::ListValue> request_headers_;
131 scoped_ptr<base::ListValue> response_headers_; 132 std::unique_ptr<base::ListValue> response_headers_;
132 133
133 int extra_info_spec_; 134 int extra_info_spec_;
134 135
135 // Used to determine the frameId and parentFrameId. 136 // Used to determine the frameId and parentFrameId.
136 int render_process_id_; 137 int render_process_id_;
137 int render_frame_id_; 138 int render_frame_id_;
138 139
139 DISALLOW_COPY_AND_ASSIGN(WebRequestEventDetails); 140 DISALLOW_COPY_AND_ASSIGN(WebRequestEventDetails);
140 }; 141 };
141 142
142 } // namespace extensions 143 } // namespace extensions
143 144
144 #endif // EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_EVENT_DETAILS_H_ 145 #endif // EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_EVENT_DETAILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698