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

Side by Side Diff: chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_api.cc

Issue 2152373003: [Extensions] Code Cleanup - Remove redundant smart-ptr get()s (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_pr ivate_api.h" 5 #include "chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_pr ivate_api.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/hash.h" 8 #include "base/hash.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 const std::string& log_id) { 52 const std::string& log_id) {
53 return base::UintToString(base::Hash(security_origin + log_id)); 53 return base::UintToString(base::Hash(security_origin + log_id));
54 } 54 }
55 } // namespace 55 } // namespace
56 56
57 content::RenderProcessHost* WebrtcLoggingPrivateFunction::RphFromRequest( 57 content::RenderProcessHost* WebrtcLoggingPrivateFunction::RphFromRequest(
58 const RequestInfo& request, const std::string& security_origin) { 58 const RequestInfo& request, const std::string& security_origin) {
59 // If |guest_process_id| is defined, directly use this id to find the 59 // If |guest_process_id| is defined, directly use this id to find the
60 // corresponding RenderProcessHost. 60 // corresponding RenderProcessHost.
61 if (request.guest_process_id.get()) 61 if (request.guest_process_id.get())
62 return content::RenderProcessHost::FromID(*request.guest_process_id.get()); 62 return content::RenderProcessHost::FromID(*request.guest_process_id);
63 63
64 // Otherwise, use the |tab_id|. If there's no |tab_id| and no 64 // Otherwise, use the |tab_id|. If there's no |tab_id| and no
65 // |guest_process_id|, we can't look up the RenderProcessHost. 65 // |guest_process_id|, we can't look up the RenderProcessHost.
66 if (!request.tab_id.get()) 66 if (!request.tab_id.get())
67 return NULL; 67 return NULL;
68 68
69 int tab_id = *request.tab_id.get(); 69 int tab_id = *request.tab_id;
70 content::WebContents* contents = NULL; 70 content::WebContents* contents = NULL;
71 if (!ExtensionTabUtil::GetTabById( 71 if (!ExtensionTabUtil::GetTabById(
72 tab_id, GetProfile(), true, NULL, NULL, &contents, NULL)) { 72 tab_id, GetProfile(), true, NULL, NULL, &contents, NULL)) {
73 error_ = extensions::ErrorUtils::FormatErrorMessage( 73 error_ = extensions::ErrorUtils::FormatErrorMessage(
74 extensions::tabs_constants::kTabNotFoundError, 74 extensions::tabs_constants::kTabNotFoundError,
75 base::IntToString(tab_id)); 75 base::IntToString(tab_id));
76 return NULL; 76 return NULL;
77 } 77 }
78 if (!contents) { 78 if (!contents) {
79 error_ = extensions::ErrorUtils::FormatErrorMessage( 79 error_ = extensions::ErrorUtils::FormatErrorMessage(
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 EXTENSION_FUNCTION_VALIDATE(params.get()); 161 EXTENSION_FUNCTION_VALIDATE(params.get());
162 162
163 WebRtcLoggingHandlerHost::GenericDoneCallback callback; 163 WebRtcLoggingHandlerHost::GenericDoneCallback callback;
164 scoped_refptr<WebRtcLoggingHandlerHost> webrtc_logging_handler_host = 164 scoped_refptr<WebRtcLoggingHandlerHost> webrtc_logging_handler_host =
165 PrepareTask(params->request, params->security_origin, &callback); 165 PrepareTask(params->request, params->security_origin, &callback);
166 if (!webrtc_logging_handler_host.get()) 166 if (!webrtc_logging_handler_host.get())
167 return false; 167 return false;
168 168
169 std::unique_ptr<MetaDataMap> meta_data(new MetaDataMap()); 169 std::unique_ptr<MetaDataMap> meta_data(new MetaDataMap());
170 for (const MetaDataEntry& entry : params->meta_data) 170 for (const MetaDataEntry& entry : params->meta_data)
171 (*meta_data.get())[entry.key] = entry.value; 171 (*meta_data)[entry.key] = entry.value;
172 172
173 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( 173 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind(
174 &WebRtcLoggingHandlerHost::SetMetaData, webrtc_logging_handler_host, 174 &WebRtcLoggingHandlerHost::SetMetaData, webrtc_logging_handler_host,
175 base::Passed(&meta_data), callback)); 175 base::Passed(&meta_data), callback));
176 176
177 return true; 177 return true;
178 } 178 }
179 179
180 bool WebrtcLoggingPrivateStartFunction::RunAsync() { 180 bool WebrtcLoggingPrivateStartFunction::RunAsync() {
181 std::unique_ptr<Start::Params> params(Start::Params::Create(*args_)); 181 std::unique_ptr<Start::Params> params(Start::Params::Create(*args_));
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 base::Bind( 509 base::Bind(
510 &WebrtcLoggingPrivateStopWebRtcEventLoggingFunction::FireCallback, 510 &WebrtcLoggingPrivateStopWebRtcEventLoggingFunction::FireCallback,
511 this), 511 this),
512 base::Bind( 512 base::Bind(
513 &WebrtcLoggingPrivateStopWebRtcEventLoggingFunction::FireErrorCallback, 513 &WebrtcLoggingPrivateStopWebRtcEventLoggingFunction::FireErrorCallback,
514 this)); 514 this));
515 return true; 515 return true;
516 } 516 }
517 517
518 } // namespace extensions 518 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698