Files
palemoon27/netwerk/cache2/CacheIOThread.h
T
roytam1 65d6aee9e0 import change from rmottola/Arctic-Fox:
- Bug 1132141 - Update storage when ServiceWorker registration fails. (5bf56ab4f)
- Bug 1001691 - WorkerPrivate::LoadInfo -> WorkerLoadInfo (bc017200f)
- Bug 1001691 - Move WorkerType out of WorkerPrivate.h (02751f7b6)
- Bug 1131882 - Associate ServiceWorkers with underlying ServiceWorkerInfo. (4492ae042)
- Bug 1131874 - ServiceWorker persistence activation fixes. (cd4f32309)
- Bug 1142015 - Add source for messages dispatched to a Service Worker. (25b685a06)
- Bug 1053275 - Exempt ServiceWorkers from per domain thread limits. (f67251f0d)
- Bug 1139561 - Various small ServiceWorker test fixes. (dbd0beae4)
- Bug 1130688 - Implement additional scope checking in service worker registration. (cbd8fee66)
- Bug 1142841: Convert all nsRefPtr<nsIRunnable> to nsCOMPtr<nsIRunnable>. r=ehsan (9d4e51880)
- Bug 1134462 - Synthesize status and headers from Response returned by ServiceWorker. (8203ae32b)
- Bug 1134462 - allow null body. (1490bb9bd)
- Bug 1141332 - Disable content decoding and use decoded length on intercepted channels. (2eec7968b)
- Bug 1134330 - Mark fetch events as reloads appropriately. (a3025a42a)
- Bug 1136757 - Add direct Response overload for FetchEvent.respondWith(). (a33248935)
- Bug 1134462 - Cleanup Promise usage in fetch test SW. (fbe9f4cd5)
- Bug 1134462 followup: Add missing MOZ_OVERRIDE annotation to SynthesizeStatus impls in SynthesizeStatus.h. (fb34b64d4)
- Bug 1142124 - Never revalidate cache entries for synthesized responses. (0f4842e41)
- Bug 1143155 - Filtered response stores internal response and allows access to headers. (956c334b1)
- Bug 1133861 - Enable the Fetch API by default. (e05918105)
- Bug 1140791 - Run fetch tests on main thread and workers. (e672969d6)
- Bug 1144819 - Change JS_DefineProperty APIs to treat getter=nullptr and setter=nullptr as indicating class getter/setter ops only for data properties. (e030ab7d6)
2019-06-18 20:09:32 +08:00

105 lines
2.9 KiB
C++

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef CacheIOThread__h__
#define CacheIOThread__h__
#include "nsIThreadInternal.h"
#include "nsISupportsImpl.h"
#include "prthread.h"
#include "nsTArray.h"
#include "nsAutoPtr.h"
#include "mozilla/Monitor.h"
#include "mozilla/DebugOnly.h"
class nsIRunnable;
namespace mozilla {
namespace net {
class CacheIOThread : public nsIThreadObserver
{
virtual ~CacheIOThread();
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSITHREADOBSERVER
CacheIOThread();
enum ELevel {
OPEN_PRIORITY,
READ_PRIORITY,
OPEN,
READ,
MANAGEMENT,
WRITE,
CLOSE,
INDEX,
EVICT,
LAST_LEVEL,
// This is actually executed as the first level, but we want this enum
// value merely as an indicator while other values are used as indexes
// to the queue array. Hence put at end and not as the first.
XPCOM_LEVEL
};
nsresult Init();
nsresult Dispatch(nsIRunnable* aRunnable, uint32_t aLevel);
// Makes sure that any previously posted event to OPEN or OPEN_PRIORITY
// levels (such as file opennings and dooms) are executed before aRunnable
// that is intended to evict stuff from the cache.
nsresult DispatchAfterPendingOpens(nsIRunnable* aRunnable);
bool IsCurrentThread();
/**
* Callable only on this thread, checks if there is an event waiting in
* the event queue with a higher execution priority. If so, the result
* is true and the current event handler should break it's work and return
* from Run() method immediately. The event handler will be rerun again
* when all more priority events are processed. Events pending after this
* handler (i.e. the one that called YieldAndRerun()) will not execute sooner
* then this handler is executed w/o a call to YieldAndRerun().
*/
static bool YieldAndRerun()
{
return sSelf ? sSelf->YieldInternal() : false;
}
nsresult Shutdown();
already_AddRefed<nsIEventTarget> Target();
// Memory reporting
size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
private:
static void ThreadFunc(void* aClosure);
void ThreadFunc();
void LoopOneLevel(uint32_t aLevel);
bool EventsPending(uint32_t aLastLevel = LAST_LEVEL);
nsresult DispatchInternal(nsIRunnable* aRunnable, uint32_t aLevel);
bool YieldInternal();
static CacheIOThread* sSelf;
mozilla::Monitor mMonitor;
PRThread* mThread;
nsCOMPtr<nsIThread> mXPCOMThread;
uint32_t mLowestLevelWaiting;
uint32_t mCurrentlyExecutingLevel;
nsTArray<nsCOMPtr<nsIRunnable> > mEventQueue[LAST_LEVEL];
bool mHasXPCOMEvents;
bool mRerunCurrentEvent;
bool mShutdown;
DebugOnly<bool> mInsideLoop;
};
} // net
} // mozilla
#endif