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

Unified Diff: chrome/browser/extensions/api/gcd_private/privet_v3_session.cc

Issue 1441403005: Use shared shared URLRequestContextGetter for all gcd_private sessions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@context5
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/gcd_private/privet_v3_session.cc
diff --git a/chrome/browser/extensions/api/gcd_private/privet_v3_session.cc b/chrome/browser/extensions/api/gcd_private/privet_v3_session.cc
index 5564df32dbb68aec80b1bdcd0e162753d96bf764..d5d70f09fcdce5f58b657bf0cb898672b9413754 100644
--- a/chrome/browser/extensions/api/gcd_private/privet_v3_session.cc
+++ b/chrome/browser/extensions/api/gcd_private/privet_v3_session.cc
@@ -10,6 +10,7 @@
#include "base/logging.h"
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
+#include "chrome/browser/extensions/api/gcd_private/privet_v3_context_getter.h"
#include "chrome/browser/local_discovery/privet_constants.h"
#include "chrome/browser/local_discovery/privet_http.h"
#include "chrome/browser/local_discovery/privet_http_impl.h"
@@ -209,12 +210,15 @@ void PrivetV3Session::FetcherDelegate::OnTimeout() {
}
PrivetV3Session::PrivetV3Session(
- const scoped_refptr<net::URLRequestContextGetter>& context_getter,
+ const scoped_refptr<PrivetV3ContextGetter>& context_getter,
const net::HostPortPair& host_port)
: client_(new local_discovery::PrivetHTTPClientImpl("",
host_port,
context_getter)),
- weak_ptr_factory_(this) {}
+ context_getter_(context_getter),
+ weak_ptr_factory_(this) {
+ CHECK(context_getter_);
+}
PrivetV3Session::~PrivetV3Session() {
Cancel();
@@ -367,9 +371,18 @@ void PrivetV3Session::OnPairingConfirmDone(
return callback.Run(Result::STATUS_SESSIONERROR);
}
- // From now use only https with fixed certificate.
VLOG(1) << "Expected certificate: " << fingerprint;
- client_->SwitchToHttps(https_port_, hash);
+ context_getter_->AddPairedHost(
+ client_->GetHost(), hash,
+ base::Bind(&PrivetV3Session::OnPairedHostAddedToContext,
+ weak_ptr_factory_.GetWeakPtr(), auth_code, callback));
+}
+
+void PrivetV3Session::OnPairedHostAddedToContext(
+ const std::string& auth_code,
+ const ResultCallback& callback) {
+ // Now use https with fixed certificate.
+ client_->SwitchToHttps(https_port_);
std::string auth_code_base64;
base::Base64Encode(auth_code, &auth_code_base64);

Powered by Google App Engine
This is Rietveld 408576698