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

Unified Diff: chrome/browser/net/chrome_sdch_policy.cc

Issue 664263002: Restructure SDCH layering to allow more separation (observer/1->[0,n] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync'd to p300953. Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/net/chrome_sdch_policy.cc
diff --git a/chrome/browser/net/chrome_sdch_policy.cc b/chrome/browser/net/chrome_sdch_policy.cc
new file mode 100644
index 0000000000000000000000000000000000000000..be98acfd0514f18132bb640a4baa8d43579d8d76
--- /dev/null
+++ b/chrome/browser/net/chrome_sdch_policy.cc
@@ -0,0 +1,38 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/net/chrome_sdch_policy.h"
+
+#include "base/bind.h"
+#include "net/base/sdch_manager.h"
+
+ChromeSdchPolicy::ChromeSdchPolicy(net::SdchManager* sdch_manager,
+ net::URLRequestContext* context)
+ : manager_(sdch_manager),
+ // Because |fetcher_| is owned by ChromeSdchPolicy, the
+ // ChromeSdchPolicy object will be available for the lifetime
+ // of |fetcher_|.
Ryan Sleevi 2014/11/04 21:40:44 1) I'm not sure what this comment is communicating
Randy Smith (Not in Mondays) 2014/11/05 20:35:01 Ok, just being over-paranoid about documenting own
+ fetcher_(context, base::Bind(&ChromeSdchPolicy::OnDictionaryFetched,
+ base::Unretained(this))) {
+ manager_->AddObserver(this);
+}
+
+ChromeSdchPolicy::~ChromeSdchPolicy() {
+ manager_->RemoveObserver(this);
+}
+
+void ChromeSdchPolicy::OnDictionaryFetched(const std::string& dictionary_text,
+ const GURL& dictionary_url) {
+ manager_->AddSdchDictionary(dictionary_text, dictionary_url);
+}
+
+void ChromeSdchPolicy::OnGetDictionary(net::SdchManager* manager,
+ const GURL& request_url,
+ const GURL& dictionary_url) {
+ fetcher_.Schedule(dictionary_url);
+}
+
+void ChromeSdchPolicy::OnClearDictionaries(net::SdchManager* manager) {
+ fetcher_.Cancel();
+}

Powered by Google App Engine
This is Rietveld 408576698