mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 827311 - Remote file update notifications. r=bent a=blocking-basecamp
This commit is contained in:
parent
0d7132b10a
commit
fd87c9795b
@ -1285,7 +1285,7 @@ BluetoothOppManager::OnDisconnect()
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (obs) {
|
||||
obs->NotifyObservers(mDsFile, "file-watcher-update", data.get());
|
||||
obs->NotifyObservers(mDsFile, "file-watcher-notify", data.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -916,7 +916,7 @@ public:
|
||||
nsString data;
|
||||
CopyASCIItoUTF16(mType, data);
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
obs->NotifyObservers(mFile, "file-watcher-update", data.get());
|
||||
obs->NotifyObservers(mFile, "file-watcher-notify", data.get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsDOMEventTargetHelper.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
|
||||
class DeviceStorageFile MOZ_FINAL
|
||||
: public nsISupports {
|
||||
@ -43,6 +44,18 @@ private:
|
||||
void AppendRelativePath();
|
||||
};
|
||||
|
||||
class FileUpdateDispatcher MOZ_FINAL
|
||||
: public nsIObserver
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
static FileUpdateDispatcher* GetSingleton();
|
||||
private:
|
||||
static mozilla::StaticRefPtr<FileUpdateDispatcher> sSingleton;
|
||||
};
|
||||
|
||||
class nsDOMDeviceStorage MOZ_FINAL
|
||||
: public nsIDOMDeviceStorage
|
||||
, public nsDOMEventTargetHelper
|
||||
|
@ -223,6 +223,56 @@ DeviceStorageTypeChecker::GetAccessForRequest(const DeviceStorageRequestType aRe
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS1(FileUpdateDispatcher, nsIObserver)
|
||||
|
||||
mozilla::StaticRefPtr<FileUpdateDispatcher> FileUpdateDispatcher::sSingleton;
|
||||
|
||||
FileUpdateDispatcher*
|
||||
FileUpdateDispatcher::GetSingleton()
|
||||
{
|
||||
if (sSingleton) {
|
||||
return sSingleton;
|
||||
}
|
||||
|
||||
sSingleton = new FileUpdateDispatcher();
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
obs->AddObserver(sSingleton, "file-watcher-notify", false);
|
||||
ClearOnShutdown(&sSingleton);
|
||||
|
||||
return sSingleton;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
FileUpdateDispatcher::Observe(nsISupports *aSubject,
|
||||
const char *aTopic,
|
||||
const PRUnichar *aData)
|
||||
{
|
||||
if (XRE_GetProcessType() != GeckoProcessType_Default) {
|
||||
|
||||
DeviceStorageFile* file = static_cast<DeviceStorageFile*>(aSubject);
|
||||
if (!file || !file->mFile) {
|
||||
NS_WARNING("Device storage file looks invalid!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsString fullpath;
|
||||
nsresult rv = file->mFile->GetPath(fullpath);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Could not get path from the nsIFile!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
ContentChild::GetSingleton()->SendFilePathUpdateNotify(file->mStorageType,
|
||||
fullpath,
|
||||
NS_ConvertUTF16toUTF8(aData));
|
||||
} else {
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
obs->NotifyObservers(aSubject, "file-watcher-update", aData);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class IOEventComplete : public nsRunnable
|
||||
{
|
||||
public:
|
||||
@ -240,7 +290,8 @@ public:
|
||||
nsString data;
|
||||
CopyASCIItoUTF16(mType, data);
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
obs->NotifyObservers(mFile, "file-watcher-update", data.get());
|
||||
|
||||
obs->NotifyObservers(mFile, "file-watcher-notify", data.get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -343,6 +343,9 @@ ContentChild::InitXPCOM()
|
||||
bool isOffline;
|
||||
SendGetXPCOMProcessAttributes(&isOffline);
|
||||
RecvSetOffline(isOffline);
|
||||
|
||||
DebugOnly<FileUpdateDispatcher*> observer = FileUpdateDispatcher::GetSingleton();
|
||||
NS_ASSERTION(observer, "FileUpdateDispatcher is null");
|
||||
}
|
||||
|
||||
PMemoryReportRequestChild*
|
||||
@ -1010,7 +1013,7 @@ ContentChild::RecvFlushMemory(const nsString& reason)
|
||||
mozilla::services::GetObserverService();
|
||||
if (os)
|
||||
os->NotifyObservers(nullptr, "memory-pressure", reason.get());
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -507,6 +507,9 @@ ContentParent::Init()
|
||||
unused << SendActivateA11y();
|
||||
}
|
||||
#endif
|
||||
|
||||
DebugOnly<FileUpdateDispatcher*> observer = FileUpdateDispatcher::GetSingleton();
|
||||
NS_ASSERTION(observer, "FileUpdateDispatcher is null");
|
||||
}
|
||||
|
||||
void
|
||||
@ -1969,6 +1972,25 @@ ContentParent::RecvAsyncMessage(const nsString& aMsg,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ContentParent::RecvFilePathUpdateNotify(const nsString& aType, const nsString& aFilePath, const nsCString& aReason)
|
||||
{
|
||||
nsCOMPtr<nsIFile> file;
|
||||
nsresult rv = NS_NewLocalFile(aFilePath, false, getter_AddRefs(file));
|
||||
if (NS_FAILED(rv)) {
|
||||
// ignore
|
||||
return true;
|
||||
}
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(aType, file);
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (!obs) {
|
||||
return false;
|
||||
}
|
||||
obs->NotifyObservers(dsf, "file-watcher-update", NS_ConvertASCIItoUTF16(aReason).get());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ContentParent::RecvAddGeolocationListener(const IPC::Principal& aPrincipal)
|
||||
{
|
||||
|
@ -302,6 +302,10 @@ private:
|
||||
virtual bool RecvAsyncMessage(const nsString& aMsg,
|
||||
const ClonedMessageData& aData);
|
||||
|
||||
virtual bool RecvFilePathUpdateNotify(const nsString& aType,
|
||||
const nsString& aFilePath,
|
||||
const nsCString& aReason);
|
||||
|
||||
virtual bool RecvAddGeolocationListener(const IPC::Principal& aPrincipal);
|
||||
virtual bool RecvRemoveGeolocationListener();
|
||||
virtual bool RecvSetGeolocationHigherAccuracy(const bool& aEnable);
|
||||
|
@ -443,6 +443,9 @@ parent:
|
||||
|
||||
async AudioChannelChangedNotification();
|
||||
|
||||
async FilePathUpdateNotify(nsString aType,
|
||||
nsString aFilepath,
|
||||
nsCString aReason);
|
||||
both:
|
||||
AsyncMessage(nsString aMessage, ClonedMessageData aData);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user