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

Side by Side Diff: chrome/browser/net/sdch_dictionary_fetcher.h

Issue 20254: Fetch SDCH dictionary as soon as current URL fetch completes... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // Support modularity by calling to load a new SDCH filter dictionary. 5 // Support modularity by calling to load a new SDCH filter dictionary.
6 // Note that this sort of calling can't be done in the /net directory, as it has 6 // Note that this sort of calling can't be done in the /net directory, as it has
7 // no concept of the HTTP cache (which is only visible at the browser level). 7 // no concept of the HTTP cache (which is only visible at the browser level).
8 8
9 #ifndef CHROME_BROWSER_NET_SDCH_DICTIONARY_FETCHER_H_ 9 #ifndef CHROME_BROWSER_NET_SDCH_DICTIONARY_FETCHER_H_
10 #define CHROME_BROWSER_NET_SDCH_DICTIONARY_FETCHER_H_ 10 #define CHROME_BROWSER_NET_SDCH_DICTIONARY_FETCHER_H_
11 11
12 #include <queue> 12 #include <queue>
13 #include <string> 13 #include <string>
14 14
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/scoped_ptr.h"
16 #include "base/task.h" 17 #include "base/task.h"
17 #include "chrome/browser/net/url_fetcher.h" 18 #include "chrome/browser/net/url_fetcher.h"
18 #include "net/base/sdch_manager.h" 19 #include "net/base/sdch_manager.h"
19 20
20 class SdchDictionaryFetcher : public URLFetcher::Delegate, 21 class SdchDictionaryFetcher : public URLFetcher::Delegate,
21 public SdchFetcher { 22 public SdchFetcher {
22 public: 23 public:
23 SdchDictionaryFetcher() : 24 SdchDictionaryFetcher() :
24 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), 25 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)),
25 task_is_pending_(false) {} 26 task_is_pending_(false) {}
26 virtual ~SdchDictionaryFetcher() {} 27 virtual ~SdchDictionaryFetcher() {}
27 28
28 // Implementation of SdchFetcher class. 29 // Implementation of SdchFetcher class.
29 // This method gets the requested dictionary, and then calls back into the 30 // This method gets the requested dictionary, and then calls back into the
30 // SdchManager class with the dictionary's text. 31 // SdchManager class with the dictionary's text.
31 virtual void Schedule(const GURL& dictionary_url); 32 virtual void Schedule(const GURL& dictionary_url);
32 33
33 private: 34 private:
34 // Delay between Schedule and actual download. 35 // Delay in ms between Schedule and actual download.
35 static const int kMsDelayFromRequestTillDownload = 15000; 36 // This leaves the URL in a queue, which is de-duped, so that there is less
37 // chance we'll try to load the same URL multiple times when a pile of
38 // page subresources (or tabs opened in parallel) all suggest the dictionary.
39 static const int kMsDelayFromRequestTillDownload = 100;
36 40
37 // Ensure the download after the above delay. 41 // Ensure the download after the above delay.
38 void ScheduleDelayedRun(); 42 void ScheduleDelayedRun();
39 43
40 // Make sure we're processing (or waiting for) the the arrival of the next URL 44 // Make sure we're processing (or waiting for) the the arrival of the next URL
41 // in the |fetch_queue_|. 45 // in the |fetch_queue_|.
42 void StartFetching(); 46 void StartFetching();
43 47
44 // Implementation of URLFetcher::Delegate. Called after transmission 48 // Implementation of URLFetcher::Delegate. Called after transmission
45 // completes (either successfully or with failure). 49 // completes (either successfully or with failure).
(...skipping 13 matching lines...) Expand all
59 // Always spread out the dictionary fetches, so that they don't steal 63 // Always spread out the dictionary fetches, so that they don't steal
60 // bandwidth from the actual page load. Create delayed tasks to spread out 64 // bandwidth from the actual page load. Create delayed tasks to spread out
61 // the download. 65 // the download.
62 ScopedRunnableMethodFactory<SdchDictionaryFetcher> method_factory_; 66 ScopedRunnableMethodFactory<SdchDictionaryFetcher> method_factory_;
63 bool task_is_pending_; 67 bool task_is_pending_;
64 68
65 DISALLOW_COPY_AND_ASSIGN(SdchDictionaryFetcher); 69 DISALLOW_COPY_AND_ASSIGN(SdchDictionaryFetcher);
66 }; 70 };
67 71
68 #endif // CHROME_BROWSER_NET_SDCH_DICTIONARY_FETCHER_H_ 72 #endif // CHROME_BROWSER_NET_SDCH_DICTIONARY_FETCHER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/net/sdch_dictionary_fetcher.cc » ('j') | net/url_request/url_request_http_job.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698