I've changed things to use a CabUpdaterBase class and an
implementation class for each of IE Mobile and Opera Mobile. I've also
fixed the style problems.
New snapshot uploaded and patch attached.
Steve
Change 9877173 by stevebl...@steveblock-gears1 on 2009/01/27 15:56:31 *pending*
Modifies CabUpdater to pass a BrowsingContext through to the AsyncTask
used to check for updates and to download the CAB. Mailed on behalf of Opera.
R=andreip
[email protected],[email protected],[email protected]
DELTA=57 (34 added, 1 deleted, 22 changed)
OCL=9877173
Affected files ...
... //depot/googleclient/gears/opensource/gears/Makefile#229 edit
... //depot/googleclient/gears/opensource/gears/base/ie/bho.cc#16 edit
... //depot/googleclient/gears/opensource/gears/base/opera/opera_utils.cc#3 edit
...
//depot/googleclient/gears/opensource/gears/installer/common/cab_updater.cc#2
edit
...
//depot/googleclient/gears/opensource/gears/installer/common/cab_updater.h#2
edit
...
//depot/googleclient/gears/opensource/gears/installer/common/download_task.cc#2
edit
...
//depot/googleclient/gears/opensource/gears/installer/common/download_task.h#2
edit
...
//depot/googleclient/gears/opensource/gears/installer/common/periodic_checker.cc#3
edit
...
//depot/googleclient/gears/opensource/gears/installer/common/periodic_checker.h#4
edit
...
//depot/googleclient/gears/opensource/gears/installer/iemobile/cab_updater_ie.cc#1
add
...
//depot/googleclient/gears/opensource/gears/installer/iemobile/cab_updater_ie.h#1
add
...
//depot/googleclient/gears/opensource/gears/installer/opera/cab_updater_op.cc#1
add
...
//depot/googleclient/gears/opensource/gears/installer/opera/cab_updater_op.h#1
add
==== //depot/googleclient/gears/opensource/gears/Makefile#229 -
c:\MyDocs\Gears1/googleclient/gears/opensource/gears/Makefile ====
# action=edit type=text
--- googleclient/gears/opensource/gears/Makefile 2009-01-27
21:36:40.000000000 +0000
+++ googleclient/gears/opensource/gears/Makefile 2009-01-29
13:10:43.000000000 +0000
@@ -2062,6 +2062,10 @@
installer/iemobile \
$(NULL)
+IEMOBILE_CPPSRCS += \
+ cab_updater_ie.cc \
+ $(NULL)
+
IEMOBILE_WINCESETUP_CPPSRCS += \
process_restarter.cc \
setup.cc \
@@ -2087,6 +2091,10 @@
OPERA_VPATH += \
installer/common \
installer/opera \
+ $(NULL)
+
+OPERA_CPPSRCS += \
+ cab_updater_op.cc \
$(NULL)
OPERA_WINCESETUP_CPPSRCS += \
==== //depot/googleclient/gears/opensource/gears/base/ie/bho.cc#16 -
c:\MyDocs\Gears1/googleclient/gears/opensource/gears/base/ie/bho.cc ====
# action=edit type=xtext
--- googleclient/gears/opensource/gears/base/ie/bho.cc 2009-01-29
13:43:43.000000000 +0000
+++ googleclient/gears/opensource/gears/base/ie/bho.cc 2009-01-29
12:55:27.000000000 +0000
@@ -34,7 +34,7 @@
#include "gears/base/common/common.h"
#include "gears/base/common/detect_version_collision.h"
#include "gears/base/ie/activex_utils.h"
-#include "gears/installer/common/cab_updater.h"
+#include "gears/installer/iemobile/cab_updater_ie.h"
#include "gears/localserver/ie/http_intercept.h"
// TODO(steveblock): Fix this GUID. See bug 406.
@@ -65,7 +65,7 @@
assert(NULL == browser_window_);
site->get_HWND(reinterpret_cast<long*>(&browser_window_));
- static CabUpdater updater;
+ static IECabUpdater updater;
updater.Start(browser_window_, kGuid);
}
return S_OK;
==== //depot/googleclient/gears/opensource/gears/base/opera/opera_utils.cc#3 -
c:\MyDocs\Gears1/googleclient/gears/opensource/gears/base/opera/opera_utils.cc
====
# action=edit type=text
--- googleclient/gears/opensource/gears/base/opera/opera_utils.cc
2009-01-27 18:26:02.000000000 +0000
+++ googleclient/gears/opensource/gears/base/opera/opera_utils.cc
2009-01-29 13:19:26.000000000 +0000
@@ -35,7 +35,7 @@
#include "third_party/opera/opera_worker_interface.h"
#ifdef OS_WINCE
-#include "gears/installer/common/cab_updater.h"
+#include "gears/installer/opera/cab_updater_op.h"
static const char16* kGuid = L"%7B000C0320-09CE-4D7E-B3C9-66B2ACB7FF80%7D";
#endif
@@ -133,7 +133,10 @@
#ifdef OS_WINCE
HWND opera_window = ::FindWindow(L"Opera_MainWndClass", NULL);
- static CabUpdater updater;
+ // TODO([email protected]): Move this code to a location where we have access
+ // to a valid browsing context.
+ BrowsingContext *browsing_context = NULL;
+ static OPCabUpdater updater(browsing_context);
updater.Start(opera_window, kGuid);
#endif
}
====
//depot/googleclient/gears/opensource/gears/installer/common/cab_updater.cc#2 -
c:\MyDocs\Gears1/googleclient/gears/opensource/gears/installer/common/cab_updater.cc
====
# action=edit type=text
--- googleclient/gears/opensource/gears/installer/common/cab_updater.cc
2009-01-27 17:14:38.000000000 +0000
+++ googleclient/gears/opensource/gears/installer/common/cab_updater.cc
2009-01-29 13:31:37.000000000 +0000
@@ -33,27 +33,25 @@
// The topic for the message system.
-const char16* kTopic = STRING16(L"Cab Update Event");
+static const char16* kTopic = STRING16(L"Cab Update Event");
// The key for ThreadLocals.
-const ThreadLocals::Slot kThreadLocalKey = ThreadLocals::Alloc();
+static const ThreadLocals::Slot kThreadLocalKey = ThreadLocals::Alloc();
-const char16 *kGearsCabName = L"gears-wince-opt.cab";
-
-// The delay before the first update.
-const int32 kFirstUpdatePeriod = (1000 * 60 * 2); // 2 minutes
// The time interval between the rest of the update checks.
-const int32 kUpdatePeriod = (1000 * 60 * 60 * 24); // 24 hours
+static const int kUpdatePeriod = (1000 * 60 * 60 * 24); // 24 hours
// A grace period after a connection event. Setting up a new connection
// can take time so we wait a little after the event.
-const int32 kGracePeriod = (1000 * 30); // 30 seconds
+static const int kGracePeriod = (1000 * 30); // 30 seconds
-CabUpdater::CabUpdater()
- : checker_(PeriodicChecker::CreateChecker()),
+CabUpdaterBase::CabUpdaterBase()
+ : checker_(NULL),
is_showing_update_dialog_(false),
- download_task_(NULL) {
+ download_task_(NULL),
+ first_update_period_(0),
+ module_name_(NULL) {
}
-CabUpdater::~CabUpdater() {
+CabUpdaterBase::~CabUpdaterBase() {
assert(checker_);
delete checker_;
if (download_task_) {
@@ -61,11 +59,12 @@
}
}
-void CabUpdater::Start(HWND browser_window, std::string16 guid) {
+void CabUpdaterBase::Start(HWND browser_window, std::string16 guid) {
browser_window_ = browser_window;
assert(browser_window_);
assert(checker_);
- if (checker_->Init(kFirstUpdatePeriod, kUpdatePeriod, kGracePeriod, guid,
+ assert(first_update_period_ > 0);
+ if (checker_->Init(first_update_period_, kUpdatePeriod, kGracePeriod, guid,
this)) {
MessageService::GetInstance()->AddObserver(this, kTopic);
// We get stopped when the DLL unloads.
@@ -74,7 +73,7 @@
}
}
-void CabUpdater::OnNotify(MessageService *service,
+void CabUpdaterBase::OnNotify(MessageService *service,
const char16 *topic,
const NotificationData *data) {
assert(wcscmp(topic, kTopic) == 0);
@@ -108,9 +107,9 @@
// Internal
// static
-void CabUpdater::Stop(void* self) {
+void CabUpdaterBase::Stop(void* self) {
assert(self);
- CabUpdater* updater = reinterpret_cast<CabUpdater*>(self);
+ CabUpdaterBase* updater = reinterpret_cast<CabUpdaterBase*>(self);
// Stop the periodic checker, without waiting for it to clean up. In general
// this is dangerous, because the periodic checker's worker thread may
attempt
// to access the object's internals, or call back to this object, after these
@@ -123,8 +122,9 @@
MessageService::GetInstance()->RemoveObserver(updater, kTopic);
}
-bool CabUpdater::ShowUpdateAvailableDialog() {
- HMODULE module = GetModuleHandle(PRODUCT_SHORT_NAME);
+bool CabUpdaterBase::ShowUpdateAvailableDialog() {
+ assert(module_name_);
+ HMODULE module = GetModuleHandle(module_name_);
if (!module) return false;
// Load the dialog strings
LPCTSTR message = reinterpret_cast<LPCTSTR>(
@@ -146,8 +146,9 @@
MB_YESNO | MB_ICONQUESTION));
}
-bool CabUpdater::ShowInstallationFailedDialog() {
- HMODULE module = GetModuleHandle(PRODUCT_SHORT_NAME);
+bool CabUpdaterBase::ShowInstallationFailedDialog() {
+ assert(module_name_);
+ HMODULE module = GetModuleHandle(module_name_);
if (!module) return false;
// Load the dialog strings
LPCTSTR message = reinterpret_cast<LPCTSTR>(
@@ -167,23 +168,8 @@
return true;
}
-// PeriodicChecker::ListenerInterface implementation
-void CabUpdater::UpdateUrlAvailable(const std::string16 &url) {
- // Start the download task
- MutexLock lock(&download_task_mutex_);
- if (download_task_ == NULL) {
- // Cache the temp file we use for the download and start the download.
-
- if (File::GetBaseTemporaryDirectory(&temp_file_path_)) {
- temp_file_path_ += kGearsCabName;
- download_task_ =
- DownloadTask::Create(url.c_str(), temp_file_path_.c_str(), this);
- }
- }
-}
-
// DownloadTask::ListenerInterface implementation
-void CabUpdater::DownloadComplete(bool success) {
+void CabUpdaterBase::DownloadComplete(bool success) {
if (success) {
// Marshall the callback to the browser thread so that we can show the
// dialog.
====
//depot/googleclient/gears/opensource/gears/installer/common/cab_updater.h#2 -
c:\MyDocs\Gears1/googleclient/gears/opensource/gears/installer/common/cab_updater.h
====
# action=edit type=text
--- googleclient/gears/opensource/gears/installer/common/cab_updater.h
2009-01-27 17:14:39.000000000 +0000
+++ googleclient/gears/opensource/gears/installer/common/cab_updater.h
2009-01-29 13:32:25.000000000 +0000
@@ -23,8 +23,8 @@
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
-// This file defines the CabUpdater class, which uses the PeriodicChecker and
-// DownloadTask to handle automitic updating.
+// This file defines the CabUpdaterBase class, which uses the PeriodicChecker
+// and DownloadTask to handle automitic updating.
//
// 1. The PeriodicChecker is configured to check for an update after two
minutes
// and every 24 hours thereafter.
@@ -33,24 +33,24 @@
// 3. If this succeeds, we present the user with a dialog, asking if they would
// like to install the new version.
// 4. If the user agrees, we invoke wceload to install the CAB.
-// 5. The CabUpdater waits for a new update from the PeriodicChecker and
+// 5. The CabUpdaterBase waits for a new update from the PeriodicChecker and
// continues from step 2.
-#ifndef GEARS_INSTALLER_IEMOBILE_CAB_UPDATER_H__
-#define GEARS_INSTALLER_IEMOBILE_CAB_UPDATER_H__
+#ifndef GEARS_INSTALLER_COMMON_CAB_UPDATER_H__
+#define GEARS_INSTALLER_COMMON_CAB_UPDATER_H__
#include "gears/base/common/common.h"
#include "gears/base/common/message_service.h"
#include "gears/installer/common/download_task.h"
#include "gears/installer/common/periodic_checker.h"
-class CabUpdater
+class CabUpdaterBase
: public MessageObserverInterface,
public PeriodicChecker::ListenerInterface,
public DownloadTask::ListenerInterface {
public:
- CabUpdater();
- virtual ~CabUpdater();
+ CabUpdaterBase();
+ virtual ~CabUpdaterBase();
// Starts the updater. guid is the GUID used in the request query parameters.
void Start(HWND browser_window, std::string16 guid);
@@ -64,6 +64,23 @@
const char16 *topic,
const NotificationData *data);
+ protected:
+ // The periodic update checker. Owned.
+ PeriodicChecker* checker_;
+
+ // The task to download the new CAB.
+ DownloadTask *download_task_;
+ Mutex download_task_mutex_;
+
+ // The temporary file that will be used for the downloaded CAB.
+ std::string16 temp_file_path_;
+
+ // The delay before the first update.
+ int first_update_period_;
+
+ // The name of the module.
+ const char16 *module_name_;
+
private:
// Stop method called when the DLL unloads.
static void Stop(void* self);
@@ -72,28 +89,16 @@
// Shows the dialog saying that installation failed.
bool ShowInstallationFailedDialog();
- // PeriodicChecker::ListenerInterface implementation
- virtual void UpdateUrlAvailable(const std::string16 &url);
-
// DownloadTask::ListenerInterface implementation
virtual void DownloadComplete(bool success);
- // The periodic update checker. Owned.
- PeriodicChecker* checker_;
// Is the update dialog showing?
bool is_showing_update_dialog_;
-
- // The task to download the new CAB.
- DownloadTask *download_task_;
- Mutex download_task_mutex_;
// The window that will be used as the parent of the dialogs.
HWND browser_window_;
- // The temporary file that will be used for the downloaded CAB.
- std::string16 temp_file_path_;
-
- DISALLOW_EVIL_CONSTRUCTORS(CabUpdater);
+ DISALLOW_EVIL_CONSTRUCTORS(CabUpdaterBase);
};
-#endif // GEARS_INSTALLER_IEMOBILE_CAB_UPDATER_H__
+#endif // GEARS_INSTALLER_COMMON_CAB_UPDATER_H__
====
//depot/googleclient/gears/opensource/gears/installer/common/download_task.cc#2
-
c:\MyDocs\Gears1/googleclient/gears/opensource/gears/installer/common/download_task.cc
====
# action=edit type=text
--- googleclient/gears/opensource/gears/installer/common/download_task.cc
2009-01-27 17:14:39.000000000 +0000
+++ googleclient/gears/opensource/gears/installer/common/download_task.cc
2009-01-29 12:33:00.000000000 +0000
@@ -34,8 +34,10 @@
// static
DownloadTask *DownloadTask::Create(const char16* url,
const char16* save_path,
- ListenerInterface *listener) {
- scoped_ptr<DownloadTask> task(new DownloadTask(url, save_path, listener));
+ ListenerInterface *listener,
+ BrowsingContext *browsing_context) {
+ scoped_ptr<DownloadTask> task(
+ new DownloadTask(url, save_path, listener, browsing_context));
assert(task.get());
if (!task.get() || !task->Init() || !task->Start()) {
return NULL;
@@ -50,8 +52,9 @@
DownloadTask::DownloadTask(const char16* url,
const char16* save_path,
- ListenerInterface *listener)
- : AsyncTask(NULL),
+ ListenerInterface *listener,
+ BrowsingContext *browsing_context)
+ : AsyncTask(browsing_context),
url_(url),
save_path_(save_path),
listener_(listener) {
====
//depot/googleclient/gears/opensource/gears/installer/common/download_task.h#2
-
c:\MyDocs\Gears1/googleclient/gears/opensource/gears/installer/common/download_task.h
====
# action=edit type=text
--- googleclient/gears/opensource/gears/installer/common/download_task.h
2009-01-27 17:14:39.000000000 +0000
+++ googleclient/gears/opensource/gears/installer/common/download_task.h
2009-01-29 12:32:07.000000000 +0000
@@ -43,14 +43,16 @@
static DownloadTask *Create(const char16 *url,
const char16 *save_path,
- ListenerInterface *listener);
+ ListenerInterface *listener,
+ BrowsingContext *browsing_context);
void StopThreadAndDelete();
private:
// Use Create and StopThreadAndDelete to create and destroy
DownloadTask(const char16 *url,
const char16 *save_path,
- ListenerInterface *listener);
+ ListenerInterface *listener,
+ BrowsingContext *browsing_context);
virtual ~DownloadTask() {}
// AsyncTask implementation
====
//depot/googleclient/gears/opensource/gears/installer/common/periodic_checker.cc#3
-
c:\MyDocs\Gears1/googleclient/gears/opensource/gears/installer/common/periodic_checker.cc
====
# action=edit type=text
--- googleclient/gears/opensource/gears/installer/common/periodic_checker.cc
2009-01-27 17:14:39.000000000 +0000
+++ googleclient/gears/opensource/gears/installer/common/periodic_checker.cc
2009-01-29 12:31:29.000000000 +0000
@@ -73,7 +73,8 @@
public:
// Factory method
static VersionFetchTask *Create(const std::string16 &guid,
- HWND listener_window);
+ HWND listener_window,
+ BrowsingContext *browsing_context);
// Signals the worker thread to stop and asynchronously deletes the object.
// No further messages will be sent to the listener once a call to this
method
@@ -85,7 +86,10 @@
private:
// Use Create to create a new instance and StopThreadAndDelete to destroy.
- VersionFetchTask(const std::string16 &guid, HWND listener_window);
+ VersionFetchTask(const std::string16 &guid,
+ HWND listener_window,
+ BrowsingContext *browsing_context);
+
virtual ~VersionFetchTask() {}
// AsyncTask implementation
@@ -107,8 +111,9 @@
// static
-PeriodicChecker* PeriodicChecker::CreateChecker() {
- return new PeriodicChecker();
+PeriodicChecker* PeriodicChecker::CreateChecker(
+ BrowsingContext *browsing_context) {
+ return new PeriodicChecker(browsing_context);
}
bool PeriodicChecker::Init(int32 first_period,
@@ -125,7 +130,7 @@
(TRUE == thread_complete_event_.Create(NULL, FALSE, FALSE, NULL));
}
-PeriodicChecker::PeriodicChecker()
+PeriodicChecker::PeriodicChecker(BrowsingContext *browsing_context)
: first_period_(0),
normal_period_(0),
grace_period_(0),
@@ -136,6 +141,7 @@
timer_(1),
task_(NULL),
window_(NULL),
+ browsing_context_(browsing_context),
normal_timer_event_(false) {
}
@@ -239,7 +245,7 @@
// Depending on how the periodic checker is configured, this can fire
// while a task is running. We ignore such events.
if (!task_) {
- task_ = VersionFetchTask::Create(guid_, window_);
+ task_ = VersionFetchTask::Create(guid_, window_, browsing_context_.get());
}
handled = TRUE;
return TRUE;
@@ -300,9 +306,11 @@
// static
VersionFetchTask *VersionFetchTask::Create(const std::string16 &guid,
- HWND listener_window) {
+ HWND listener_window,
+ BrowsingContext *browsing_context) {
+
VersionFetchTask *task =
- new VersionFetchTask(guid, listener_window);
+ new VersionFetchTask(guid, listener_window, browsing_context);
if (!task) {
assert(false);
return NULL;
@@ -315,8 +323,9 @@
}
VersionFetchTask::VersionFetchTask(const std::string16 &guid,
- HWND listener_window)
- : AsyncTask(NULL),
+ HWND listener_window,
+ BrowsingContext* browsing_context)
+ : AsyncTask(browsing_context),
guid_(guid),
listener_window_(listener_window) {
assert(listener_window_);
====
//depot/googleclient/gears/opensource/gears/installer/common/periodic_checker.h#4
-
c:\MyDocs\Gears1/googleclient/gears/opensource/gears/installer/common/periodic_checker.h
====
# action=edit type=text
--- googleclient/gears/opensource/gears/installer/common/periodic_checker.h
2009-01-27 17:14:40.000000000 +0000
+++ googleclient/gears/opensource/gears/installer/common/periodic_checker.h
2009-01-29 12:28:25.000000000 +0000
@@ -30,10 +30,11 @@
// new version is available, a callback is made to the listener with the
// download URL of the new version.
-#ifndef GEARS_INSTALLER_IEMOBILE_PERIODIC_CHECKER_H__
-#define GEARS_INSTALLER_IEMOBILE_PERIODIC_CHECKER_H__
+#ifndef GEARS_INSTALLER_COMMON_PERIODIC_CHECKER_H__
+#define GEARS_INSTALLER_COMMON_PERIODIC_CHECKER_H__
#include "gears/base/common/atl_headers_win32.h"
+#include "gears/base/common/browsing_context.h"
#include <gears/base/common/string16.h>
#include "gears/base/common/wince_compatibility.h"
@@ -48,7 +49,7 @@
};
// Simple factory method.
- static PeriodicChecker* CreateChecker();
+ static PeriodicChecker *CreateChecker(BrowsingContext *browsing_context);
// Initializes the checker and sets the desired times between update checks.
// Also sets the application ID sent to the server for update checks and the
// listener for callbacks.
@@ -76,8 +77,7 @@
END_MSG_MAP()
// Internal
- PeriodicChecker();
-
+ PeriodicChecker(BrowsingContext *browsing_context);
// Message handlers.
LRESULT OnTimer(UINT message, WPARAM unused1, LPARAM unused2, BOOL &handled);
LRESULT OnFetchTaskComplete(UINT message, WPARAM success, LPARAM unused,
@@ -124,7 +124,9 @@
// The message ID used for listening to connection status events.
uint32 con_mgr_msg_;
+ scoped_refptr<BrowsingContext> browsing_context_;
+
DISALLOW_EVIL_CONSTRUCTORS(PeriodicChecker);
};
-#endif // GEARS_INSTALLER_IEMOBILE_PERIODIC_CHECKER_H__
+#endif // GEARS_INSTALLER_COMMON_PERIODIC_CHECKER_H__
====
//depot/googleclient/gears/opensource/gears/installer/iemobile/cab_updater_ie.cc#1
-
c:\MyDocs\Gears1/googleclient/gears/opensource/gears/installer/iemobile/cab_updater_ie.cc
====
# action=add type=text
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ googleclient/gears/opensource/gears/installer/iemobile/cab_updater_ie.cc
2009-01-29 13:20:48.000000000 +0000
@@ -0,0 +1,55 @@
+// Copyright 2008, Google Inc.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
notice,
+// this list of conditions and the following disclaimer in the
documentation
+// and/or other materials provided with the distribution.
+// 3. Neither the name of Google Inc. nor the names of its contributors may be
+// used to endorse or promote products derived from this software without
+// specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "gears/installer/iemobile/cab_updater_ie.h"
+
+#include "gears/base/common/file.h"
+#include "gears/base/common/thread_locals.h"
+
+static const char16 *kGearsCabName = L"gears-wince-opt.cab";
+static const int kFirstUpdatePeriod = (1000 * 60 * 2); // 2 minutes
+
+IECabUpdater::IECabUpdater() {
+ checker_ = PeriodicChecker::CreateChecker(NULL);
+ first_update_period_ = kFirstUpdatePeriod;
+ module_name_ = PRODUCT_SHORT_NAME;
+}
+
+// PeriodicChecker::ListenerInterface implementation
+void IECabUpdater::UpdateUrlAvailable(const std::string16 &url) {
+ // Start the download task
+ MutexLock lock(&download_task_mutex_);
+ if (download_task_ == NULL) {
+ // Cache the temp file we use for the download and start the download.
+
+ if (File::GetBaseTemporaryDirectory(&temp_file_path_)) {
+ temp_file_path_ += kGearsCabName;
+ download_task_ = DownloadTask::Create(url.c_str(),
+ temp_file_path_.c_str(),
+ this,
+ NULL);
+ }
+ }
+}
====
//depot/googleclient/gears/opensource/gears/installer/iemobile/cab_updater_ie.h#1
-
c:\MyDocs\Gears1/googleclient/gears/opensource/gears/installer/iemobile/cab_updater_ie.h
====
# action=add type=text
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ googleclient/gears/opensource/gears/installer/iemobile/cab_updater_ie.h
2009-01-29 12:52:09.000000000 +0000
@@ -0,0 +1,42 @@
+// Copyright 2008, Google Inc.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
notice,
+// this list of conditions and the following disclaimer in the
documentation
+// and/or other materials provided with the distribution.
+// 3. Neither the name of Google Inc. nor the names of its contributors may be
+// used to endorse or promote products derived from this software without
+// specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef GEARS_INSTALLER_IEMOBILE_CAB_UPDATER_IE_H__
+#define GEARS_INSTALLER_IEMOBILE_CAB_UPDATER_IE_H__
+
+#include "gears/installer/common/cab_updater.h"
+
+class IECabUpdater : public CabUpdaterBase {
+ public:
+ IECabUpdater();
+ virtual ~IECabUpdater() {}
+
+ // PeriodicChecker::ListenerInterface implementation
+ virtual void UpdateUrlAvailable(const std::string16 &url);
+
+ DISALLOW_EVIL_CONSTRUCTORS(IECabUpdater);
+};
+
+#endif // GEARS_INSTALLER_IEMOBILE_CAB_UPDATER_IE_H__
====
//depot/googleclient/gears/opensource/gears/installer/opera/cab_updater_op.cc#1
-
c:\MyDocs\Gears1/googleclient/gears/opensource/gears/installer/opera/cab_updater_op.cc
====
# action=add type=text
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ googleclient/gears/opensource/gears/installer/opera/cab_updater_op.cc
2009-01-29 13:28:46.000000000 +0000
@@ -0,0 +1,65 @@
+// Copyright 2008, Google Inc.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
notice,
+// this list of conditions and the following disclaimer in the
documentation
+// and/or other materials provided with the distribution.
+// 3. Neither the name of Google Inc. nor the names of its contributors may be
+// used to endorse or promote products derived from this software without
+// specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "gears/installer/opera/cab_updater_op.h"
+
+#include "gears/base/common/file.h"
+#include "gears/base/common/thread_locals.h"
+
+static const char16 *kGearsCabName = L"gears-wince-opt-opera.cab";
+// On Opera Mobile we start the update process when the user first navigates to
+// a Gears enabled page. This is so that we have a browsing context available
to
+// use for the various HTTP requests involved. We therefore keep the first
+// update period small to reduce the risk of the user navigating away from the
+// page, and thus invalidating the browsing context, before the update process
+// completes.
+static const int kFirstUpdatePeriod = (1000 * 2); // 2 seconds
+static const char16 *kModuleName = L"gearsop"; // [naming]
+
+OPCabUpdater::OPCabUpdater(BrowsingContext *browsing_context)
+ : browsing_context_(browsing_context) {
+ assert(browsing_context_);
+
+ checker_ = PeriodicChecker::CreateChecker(browsing_context_);
+ first_update_period_ = kFirstUpdatePeriod;
+ module_name_ = kModuleName;
+}
+
+// PeriodicChecker::ListenerInterface implementation
+void OPCabUpdater::UpdateUrlAvailable(const std::string16 &url) {
+ // Start the download task
+ MutexLock lock(&download_task_mutex_);
+ if (download_task_ == NULL) {
+ // Cache the temp file we use for the download and start the download.
+
+ if (File::GetBaseTemporaryDirectory(&temp_file_path_)) {
+ temp_file_path_ += kGearsCabName;
+ download_task_ = DownloadTask::Create(url.c_str(),
+ temp_file_path_.c_str(),
+ this,
+ browsing_context_);
+ }
+ }
+}
====
//depot/googleclient/gears/opensource/gears/installer/opera/cab_updater_op.h#1
-
c:\MyDocs\Gears1/googleclient/gears/opensource/gears/installer/opera/cab_updater_op.h
====
# action=add type=text
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ googleclient/gears/opensource/gears/installer/opera/cab_updater_op.h
2009-01-29 13:13:30.000000000 +0000
@@ -0,0 +1,45 @@
+// Copyright 2008, Google Inc.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
notice,
+// this list of conditions and the following disclaimer in the
documentation
+// and/or other materials provided with the distribution.
+// 3. Neither the name of Google Inc. nor the names of its contributors may be
+// used to endorse or promote products derived from this software without
+// specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef GEARS_INSTALLER_OPERA_CAB_UPDATER_OP_H__
+#define GEARS_INSTALLER_OPERA_CAB_UPDATER_OP_H__
+
+#include "gears/installer/common/cab_updater.h"
+
+class OPCabUpdater : public CabUpdaterBase {
+ public:
+ OPCabUpdater(BrowsingContext *browsing_context);
+ virtual ~OPCabUpdater() {}
+
+ // PeriodicChecker::ListenerInterface implementation
+ virtual void UpdateUrlAvailable(const std::string16 &url);
+
+ private:
+ BrowsingContext *browsing_context_;
+
+ DISALLOW_EVIL_CONSTRUCTORS(OPCabUpdater);
+};
+
+#endif // GEARS_INSTALLER_OPERA_CAB_UPDATER_OP_H__