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

Side by Side Diff: chrome/browser/spellchecker/spellcheck_host_impl.h

Issue 10392192: Remove content::URLFetcherDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More cleanup Created 8 years, 7 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HOST_IMPL_H_ 5 #ifndef CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HOST_IMPL_H_
6 #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HOST_IMPL_H_ 6 #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HOST_IMPL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/file_path.h" 13 #include "base/file_path.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/message_loop_helpers.h" 16 #include "base/message_loop_helpers.h"
17 #include "chrome/browser/spellchecker/spellcheck_host.h" 17 #include "chrome/browser/spellchecker/spellcheck_host.h"
18 #include "chrome/browser/spellchecker/spellcheck_profile_provider.h" 18 #include "chrome/browser/spellchecker/spellcheck_profile_provider.h"
19 #include "content/public/browser/notification_observer.h" 19 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h" 20 #include "content/public/browser/notification_registrar.h"
21 #include "content/public/common/url_fetcher_delegate.h" 21 #include "net/url_request/url_fetcher_delegate.h"
22
23 namespace net {
24 class URLFetcher;
25 } // namespace net
22 26
23 // This class implements the SpellCheckHost interface to provide the 27 // This class implements the SpellCheckHost interface to provide the
24 // functionalities listed below: 28 // functionalities listed below:
25 // * Adding a word to the custom dictionary; 29 // * Adding a word to the custom dictionary;
26 // * Storing the custom dictionary to the file, and read it back 30 // * Storing the custom dictionary to the file, and read it back
27 // from the file during the initialization. 31 // from the file during the initialization.
28 // * Downloading a dictionary and map it for the renderer, and; 32 // * Downloading a dictionary and map it for the renderer, and;
29 // * Calling the platform spellchecker attached to the browser; 33 // * Calling the platform spellchecker attached to the browser;
30 // 34 //
31 // To download a dictionary and initialize it without blocking the UI thread, 35 // To download a dictionary and initialize it without blocking the UI thread,
32 // this class also implements the URLFetcher::Delegate() interface. This 36 // this class also implements the URLFetcher::Delegate() interface. This
33 // initialization status is notified to the UI thread through the 37 // initialization status is notified to the UI thread through the
34 // SpellCheckProfileProvider interface. 38 // SpellCheckProfileProvider interface.
35 // 39 //
36 // We expect a profile creates an instance of this class through a factory 40 // We expect a profile creates an instance of this class through a factory
37 // method, SpellCheckHost::Create() and uses only the SpellCheckHost interface 41 // method, SpellCheckHost::Create() and uses only the SpellCheckHost interface
38 // provided by this class. 42 // provided by this class.
39 // spell_check_host_ = SpellCheckHost::Create(...) 43 // spell_check_host_ = SpellCheckHost::Create(...)
40 // 44 //
41 // Available languages for the checker, which we need to specify via Create(), 45 // Available languages for the checker, which we need to specify via Create(),
42 // can be listed using SpellCheckHost::GetAvailableLanguages() static method. 46 // can be listed using SpellCheckHost::GetAvailableLanguages() static method.
43 class SpellCheckHostImpl : public SpellCheckHost, 47 class SpellCheckHostImpl : public SpellCheckHost,
44 public content::URLFetcherDelegate, 48 public net::URLFetcherDelegate,
45 public content::NotificationObserver { 49 public content::NotificationObserver {
46 public: 50 public:
47 SpellCheckHostImpl(SpellCheckProfileProvider* profile, 51 SpellCheckHostImpl(SpellCheckProfileProvider* profile,
48 const std::string& language, 52 const std::string& language,
49 net::URLRequestContextGetter* request_context_getter, 53 net::URLRequestContextGetter* request_context_getter,
50 SpellCheckHostMetrics* metrics); 54 SpellCheckHostMetrics* metrics);
51 55
52 virtual ~SpellCheckHostImpl(); 56 virtual ~SpellCheckHostImpl();
53 57
54 void Initialize(); 58 void Initialize();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // Write a custom dictionary addition to disk. 104 // Write a custom dictionary addition to disk.
101 void WriteWordToCustomDictionary(const std::string& word); 105 void WriteWordToCustomDictionary(const std::string& word);
102 106
103 // Returns a metrics counter associated with this object, 107 // Returns a metrics counter associated with this object,
104 // or null when metrics recording is disabled. 108 // or null when metrics recording is disabled.
105 virtual SpellCheckHostMetrics* GetMetrics() const OVERRIDE; 109 virtual SpellCheckHostMetrics* GetMetrics() const OVERRIDE;
106 110
107 // Returns true if the dictionary is ready to use. 111 // Returns true if the dictionary is ready to use.
108 virtual bool IsReady() const OVERRIDE; 112 virtual bool IsReady() const OVERRIDE;
109 113
110 // content::URLFetcherDelegate implementation. Called when we finish 114 // net::URLFetcherDelegate implementation. Called when we finish
111 // downloading the spellcheck dictionary; saves the dictionary to |data_|. 115 // downloading the spellcheck dictionary; saves the dictionary to |data_|.
112 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 116 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
113 117
114 // NotificationProfile implementation. 118 // NotificationProfile implementation.
115 virtual void Observe(int type, 119 virtual void Observe(int type,
116 const content::NotificationSource& source, 120 const content::NotificationSource& source,
117 const content::NotificationDetails& details) OVERRIDE; 121 const content::NotificationDetails& details) OVERRIDE;
118 122
119 // Saves |data_| to disk. Run on the file thread. 123 // Saves |data_| to disk. Run on the file thread.
120 void SaveDictionaryData(); 124 void SaveDictionaryData();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 bool use_platform_spellchecker_; 156 bool use_platform_spellchecker_;
153 157
154 // Data received from the dictionary download. 158 // Data received from the dictionary download.
155 std::string data_; 159 std::string data_;
156 160
157 // Used for downloading the dictionary file. We don't hold a reference, and 161 // Used for downloading the dictionary file. We don't hold a reference, and
158 // it is only valid to use it on the UI thread. 162 // it is only valid to use it on the UI thread.
159 net::URLRequestContextGetter* request_context_getter_; 163 net::URLRequestContextGetter* request_context_getter_;
160 164
161 // Used for downloading the dictionary file. 165 // Used for downloading the dictionary file.
162 scoped_ptr<content::URLFetcher> fetcher_; 166 scoped_ptr<net::URLFetcher> fetcher_;
163 167
164 content::NotificationRegistrar registrar_; 168 content::NotificationRegistrar registrar_;
165 169
166 // An optional metrics counter given by the constructor. 170 // An optional metrics counter given by the constructor.
167 SpellCheckHostMetrics* metrics_; 171 SpellCheckHostMetrics* metrics_;
168 172
169 base::WeakPtrFactory<SpellCheckHostImpl> weak_ptr_factory_; 173 base::WeakPtrFactory<SpellCheckHostImpl> weak_ptr_factory_;
170 174
171 scoped_ptr<CustomWordList> custom_words_; 175 scoped_ptr<CustomWordList> custom_words_;
172 176
173 DISALLOW_COPY_AND_ASSIGN(SpellCheckHostImpl); 177 DISALLOW_COPY_AND_ASSIGN(SpellCheckHostImpl);
174 }; 178 };
175 179
176 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HOST_IMPL_H_ 180 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HOST_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_fetcher.cc ('k') | chrome/browser/spellchecker/spellcheck_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698