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

Side by Side Diff: chrome/browser/chromeos/login/apply_services_customization.h

Issue 3026048: Fetch OEM services customization manifest from URL async.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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
Property Changes:
Added: svn:mergeinfo
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_CHROMEOS_LOGIN_STRING_FETCHER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_APPLY_SERVICES_CUSTOMIZATION_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_STRING_FETCHER_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_APPLY_SERVICES_CUSTOMIZATION_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/scoped_ptr.h" 11 #include "base/scoped_ptr.h"
12 #include "base/timer.h"
12 #include "chrome/common/net/url_fetcher.h" 13 #include "chrome/common/net/url_fetcher.h"
14 #include "googleurl/src/gurl.h"
13 15
14 // This class is used to fetch an URL and store result as a string. 16 class PrefService;
15 class StringFetcher : public URLFetcher::Delegate { 17
18 namespace chromeos {
19
20 // This class fetches services customization document and apply it
21 // as soon as the document is downloaded.
22 class ApplyServicesCustomization : public URLFetcher::Delegate {
16 public: 23 public:
17 // Initiates URL fetch. 24 // This method checks if service customization has been applied and if not
18 explicit StringFetcher(const std::string& url); 25 // starts the process.
26 static void StartIfNeeded();
19 27
20 const std::string& result() const { return result_; } 28 // Registers preferences.
21 int response_code() const { return response_code_; } 29 static void RegisterPrefs(PrefService* local_state);
22 bool succeeded() const { return response_code_ == 200; } 30
31 // Returns true if service customization has been applied.
32 static bool IsApplied();
23 33
24 private: 34 private:
35 explicit ApplyServicesCustomization(const std::string& url_str);
36
37 // Initiate URL fetch, return true if the object will delete itself later.
38 bool Init();
39
40 // Initiate file fetching.
41 void StartFileFetch();
42
25 // Overriden from URLFetcher::Delegate: 43 // Overriden from URLFetcher::Delegate:
26 virtual void OnURLFetchComplete(const URLFetcher* source, 44 virtual void OnURLFetchComplete(const URLFetcher* source,
27 const GURL& url, 45 const GURL& url,
28 const URLRequestStatus& status, 46 const URLRequestStatus& status,
29 int response_code, 47 int response_code,
30 const ResponseCookies& cookies, 48 const ResponseCookies& cookies,
31 const std::string& data); 49 const std::string& data);
32 // Timer notification handler. 50
33 void OnTimeoutElapsed(); 51 // Applies given |manifest|.
52 void Apply(const std::string& manifest);
53
54 // Remember in local state status of kServicesCustomizationAppliedPref.
55 static void SetApplied(bool val);
56
57 // Services customization manifest URL.
58 GURL url_;
34 59
35 // URLFetcher instance. 60 // URLFetcher instance.
36 scoped_ptr<URLFetcher> url_fetcher_; 61 scoped_ptr<URLFetcher> url_fetcher_;
37 62
38 // Fetch result. 63 // Timer to retry fetching file if network is not available.
39 std::string result_; 64 base::OneShotTimer<ApplyServicesCustomization> retry_timer_;
40 65
41 // Received HTTP response code. 66 // How many times we already tried to fetch customization manifest file.
42 int response_code_; 67 int num_retries_;
43 68
44 DISALLOW_COPY_AND_ASSIGN(StringFetcher); 69 DISALLOW_COPY_AND_ASSIGN(ApplyServicesCustomization);
45 }; 70 };
46 71
47 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_STRING_FETCHER_H_ 72 } // namespace chromeos
73
74 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_APPLY_SERVICES_CUSTOMIZATION_H_
OLDNEW
« no previous file with comments | « chrome/browser/browser_prefs.cc ('k') | chrome/browser/chromeos/login/apply_services_customization.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698