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

Side by Side Diff: components/translate/content/browser/data_file_browser_cld_data_provider.h

Issue 424053002: Add a new "Configure" mechanism to CLD browser-side data interfaces. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sorin@'s comments Created 6 years, 4 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 2014 The Chromium Authors. All rights reserved. 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 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 COMPONENTS_TRANSLATE_CONTENT_BROWSER_DATA_FILE_BROWSER_CLD_DATA_PROVIDER _H_ 5 #ifndef COMPONENTS_TRANSLATE_CONTENT_BROWSER_DATA_FILE_BROWSER_CLD_DATA_PROVIDER _H_
6 #define COMPONENTS_TRANSLATE_CONTENT_BROWSER_DATA_FILE_BROWSER_CLD_DATA_PROVIDER _H_ 6 #define COMPONENTS_TRANSLATE_CONTENT_BROWSER_DATA_FILE_BROWSER_CLD_DATA_PROVIDER _H_
7 7
8 #include "base/files/file.h" 8 #include "base/files/file.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "components/translate/content/browser/browser_cld_data_provider.h" 13 #include "components/translate/content/browser/browser_cld_data_provider.h"
14 14
15 namespace translate { 15 namespace translate {
16 16
17 class DataFileBrowserCldDataProvider : public BrowserCldDataProvider { 17 class DataFileBrowserCldDataProvider : public BrowserCldDataProvider {
18 public: 18 public:
19 explicit DataFileBrowserCldDataProvider(content::WebContents*); 19 explicit DataFileBrowserCldDataProvider(content::WebContents*);
20 virtual ~DataFileBrowserCldDataProvider(); 20 virtual ~DataFileBrowserCldDataProvider();
21 // BrowserCldDataProvider implementations: 21 // BrowserCldDataProvider implementations:
22 virtual bool OnMessageReceived(const IPC::Message&) OVERRIDE; 22 virtual bool OnMessageReceived(const IPC::Message&) OVERRIDE;
23 virtual void OnCldDataRequest() OVERRIDE; 23 virtual void OnCldDataRequest() OVERRIDE;
24 virtual void SendCldDataResponse() OVERRIDE; 24 virtual void SendCldDataResponse() OVERRIDE;
25 25
26 // Sets the data file that this data provider will use to fulfill requests.
27 // This method does nothing if the specified path is equal to the path that
28 // is already configured. Otherwise, the specified path is cached and
29 // subsequent requests for data will attempt to load CLD data from the file
30 // at the specified path.
31 // This method is threadsafe.
32 static void SetCldDataFilePath(const base::FilePath& filePath);
33
34 // Returns the path most recently set by SetDataFilePath. The initial value
35 // prior to any such call is the empty path.
36 // This method is threadsafe.
37 static base::FilePath GetCldDataFilePath();
38
39 private: 26 private:
40 void SendCldDataResponseInternal(const base::File*, 27 void SendCldDataResponseInternal(const base::File*,
41 const uint64, 28 const uint64,
42 const uint64); 29 const uint64);
43 static void OnCldDataRequestInternal(); 30 static void OnCldDataRequestInternal();
44 31
45 content::WebContents* web_contents_; 32 content::WebContents* web_contents_;
46 scoped_ptr<base::WeakPtrFactory<DataFileBrowserCldDataProvider> > 33 scoped_ptr<base::WeakPtrFactory<DataFileBrowserCldDataProvider> >
47 weak_pointer_factory_; 34 weak_pointer_factory_;
48 35
49 DISALLOW_COPY_AND_ASSIGN(DataFileBrowserCldDataProvider); 36 DISALLOW_COPY_AND_ASSIGN(DataFileBrowserCldDataProvider);
50 }; 37 };
51 38
52 } // namespace translate 39 } // namespace translate
53 40
54 #endif // COMPONENTS_TRANSLATE_CONTENT_BROWSER_DATA_FILE_BROWSER_CLD_DATA_PROVI DER_H_ 41 #endif // COMPONENTS_TRANSLATE_CONTENT_BROWSER_DATA_FILE_BROWSER_CLD_DATA_PROVI DER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698