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

Side by Side Diff: chrome/browser/net/chrome_sdch_policy.cc

Issue 841883002: Add an eviction mechanism for SDCH dictionaries. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync'd to p310544 Created 5 years, 11 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
« no previous file with comments | « chrome/browser/net/chrome_sdch_policy.h ('k') | chrome/browser/net/sdch_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/net/chrome_sdch_policy.h"
6
7 #include "base/bind.h"
8 #include "net/base/sdch_manager.h"
9 #include "net/base/sdch_net_log_params.h"
10
11 ChromeSdchPolicy::ChromeSdchPolicy(net::SdchManager* sdch_manager,
12 net::URLRequestContext* context)
13 : manager_(sdch_manager),
14 // Because |fetcher_| is owned by ChromeSdchPolicy, the
15 // ChromeSdchPolicy object will be available for the lifetime
16 // of |fetcher_|.
17 fetcher_(context,
18 base::Bind(&ChromeSdchPolicy::OnDictionaryFetched,
19 base::Unretained(this))) {
20 manager_->AddObserver(this);
21 }
22
23 ChromeSdchPolicy::~ChromeSdchPolicy() {
24 manager_->RemoveObserver(this);
25 }
26
27 void ChromeSdchPolicy::OnDictionaryFetched(const std::string& dictionary_text,
28 const GURL& dictionary_url,
29 const net::BoundNetLog& net_log) {
30 net::SdchProblemCode rv =
31 manager_->AddSdchDictionary(dictionary_text, dictionary_url);
32 if (rv != net::SDCH_OK) {
33 net::SdchManager::SdchErrorRecovery(rv);
34 net_log.AddEvent(net::NetLog::TYPE_SDCH_DICTIONARY_ERROR,
35 base::Bind(&net::NetLogSdchDictionaryFetchProblemCallback,
36 rv, dictionary_url, true));
37 }
38 }
39
40 void ChromeSdchPolicy::OnGetDictionary(net::SdchManager* manager,
41 const GURL& request_url,
42 const GURL& dictionary_url) {
43 fetcher_.Schedule(dictionary_url);
44 }
45
46 void ChromeSdchPolicy::OnClearDictionaries(net::SdchManager* manager) {
47 fetcher_.Cancel();
48 }
OLDNEW
« no previous file with comments | « chrome/browser/net/chrome_sdch_policy.h ('k') | chrome/browser/net/sdch_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698