Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Switch to PEmbedLiteAppParent interface, cleanup view interface
  • Loading branch information
tmeshkova committed Oct 19, 2014
1 parent 3e00c8d commit 119abc8
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 201 deletions.
11 changes: 9 additions & 2 deletions embedding/embedlite/EmbedLiteApp.cpp
Expand Up @@ -245,6 +245,7 @@ EmbedLiteApp::StopChildThread()
}

mAppChild->Close();
delete mAppParent;
mAppParent = nullptr;
mAppChild = nullptr;

Expand All @@ -258,6 +259,12 @@ void _FinalStop(EmbedLiteApp* app)
app->Stop();
}

void
EmbedLiteApp::PreDestroy(EmbedLiteApp* app)
{
unused << app->mAppParent->SendPreDestroy();
}

void
EmbedLiteApp::Stop()
{
Expand All @@ -273,7 +280,7 @@ EmbedLiteApp::Stop()
} else if (!mDestroying) {
mDestroying = true;
mUILoop->PostTask(FROM_HERE,
NewRunnableMethod(mAppParent.get(), &EmbedLiteAppThreadParent::SendPreDestroy));
NewRunnableFunction(&EmbedLiteApp::PreDestroy, this));
} else {
NS_ASSERTION(mUILoop, "Start was not called before stop");
mUILoop->DoQuit();
Expand Down Expand Up @@ -411,7 +418,7 @@ EmbedLiteApp::ViewDestroyed(uint32_t id)
}
if (mDestroying && mViews.empty()) {
mUILoop->PostTask(FROM_HERE,
NewRunnableMethod(mAppParent.get(), &EmbedLiteAppThreadParent::SendPreDestroy));
NewRunnableFunction(&EmbedLiteApp::PreDestroy, this));
}
}

Expand Down
4 changes: 3 additions & 1 deletion embedding/embedlite/EmbedLiteApp.h
Expand Up @@ -25,6 +25,7 @@ class EmbedLiteAppThreadChild;
class EmbedLiteAppThreadParent;
class EmbedLiteSubThread;
class EmbedLiteView;
class PEmbedLiteAppParent;
class EmbedLiteAppListener
{
public:
Expand Down Expand Up @@ -148,13 +149,14 @@ class EmbedLiteApp
uint32_t CreateWindowRequested(const uint32_t& chromeFlags, const char* uri, const uint32_t& contextFlags, const uint32_t& parentId);
EmbedLiteAppListener* GetListener();
MessageLoop* GetUILoop();
static void PreDestroy(EmbedLiteApp*);

static EmbedLiteApp* sSingleton;
EmbedLiteAppListener* mListener;
EmbedLiteUILoop* mUILoop;

RefPtr<EmbedLiteSubThread> mSubThread;
RefPtr<EmbedLiteAppThreadParent> mAppParent;
PEmbedLiteAppParent* mAppParent;
RefPtr<EmbedLiteAppThreadChild> mAppChild;

EmbedType mEmbedType;
Expand Down
75 changes: 37 additions & 38 deletions embedding/embedlite/EmbedLiteView.cpp
Expand Up @@ -28,6 +28,7 @@ EmbedLiteView::EmbedLiteView(EmbedLiteApp* aApp, uint32_t aUniqueID, uint32_t aP
: mApp(aApp)
, mListener(NULL)
, mViewImpl(NULL)
, mViewParent(NULL)
, mUniqueID(aUniqueID)
, mParent(aParent)
{
Expand Down Expand Up @@ -65,9 +66,10 @@ EmbedLiteView::GetListener() const
}

void
EmbedLiteView::SetImpl(EmbedLiteViewIface* aViewImpl)
EmbedLiteView::SetImpl(EmbedLiteViewThreadParent* aViewImpl)
{
mViewImpl = aViewImpl;
mViewParent = aViewImpl;
}

EmbedLiteViewIface*
Expand All @@ -80,107 +82,111 @@ void
EmbedLiteView::LoadURL(const char* aUrl)
{
LOGT("url:%s", aUrl);
NS_ENSURE_TRUE(mViewImpl, );
mViewImpl->LoadURL(aUrl);
unused << mViewParent->SendLoadURL(NS_ConvertUTF8toUTF16(nsDependentCString(aUrl)));
}

void
EmbedLiteView::SetIsActive(bool aIsActive)
{
LOGT();
NS_ENSURE_TRUE(mViewImpl, );
mViewImpl->SetIsActive(aIsActive);
NS_ENSURE_TRUE(mViewParent, );
unused << mViewParent->SendSetIsActive(aIsActive);
}

void
EmbedLiteView::SetIsFocused(bool aIsFocused)
{
LOGT();
NS_ENSURE_TRUE(mViewImpl, );
mViewImpl->SetIsFocused(aIsFocused);
NS_ENSURE_TRUE(mViewParent, );
unused << mViewParent->SendSetIsFocused(aIsFocused);
}

void
EmbedLiteView::SuspendTimeouts()
{
LOGT();
NS_ENSURE_TRUE(mViewImpl, );
mViewImpl->SuspendTimeouts();
NS_ENSURE_TRUE(mViewParent, );
unused << mViewParent->SendSuspendTimeouts();
}

void
EmbedLiteView::ResumeTimeouts()
{
LOGT();
NS_ENSURE_TRUE(mViewImpl, );
mViewImpl->ResumeTimeouts();
NS_ENSURE_TRUE(mViewParent, );
unused << mViewParent->SendResumeTimeouts();
}

void EmbedLiteView::GoBack()
{
NS_ENSURE_TRUE(mViewImpl, );
mViewImpl->GoBack();
NS_ENSURE_TRUE(mViewParent, );
unused << mViewParent->SendGoBack();

}

void EmbedLiteView::GoForward()
{
NS_ENSURE_TRUE(mViewImpl, );
mViewImpl->GoForward();
NS_ENSURE_TRUE(mViewParent, );
unused << mViewParent->SendGoForward();
}

void EmbedLiteView::StopLoad()
{
NS_ENSURE_TRUE(mViewImpl, );
mViewImpl->StopLoad();
NS_ENSURE_TRUE(mViewParent, );
unused << mViewParent->SendStopLoad();

}

void EmbedLiteView::Reload(bool hard)
{
NS_ENSURE_TRUE(mViewImpl, );
mViewImpl->Reload(hard);
NS_ENSURE_TRUE(mViewParent, );
unused << mViewParent->SendReload(hard);
}

void
EmbedLiteView::LoadFrameScript(const char* aURI)
{
LOGT("uri:%s, mViewImpl:%p", aURI, mViewImpl);
NS_ENSURE_TRUE(mViewImpl, );
mViewImpl->LoadFrameScript(aURI);
NS_ENSURE_TRUE(mViewParent, );
unused << mViewParent->SendLoadFrameScript(NS_ConvertUTF8toUTF16(nsDependentCString(aURI)));
}

void
EmbedLiteView::AddMessageListener(const char* aName)
{
LOGT("name:%s", aName);
NS_ENSURE_TRUE(mViewImpl, );
mViewImpl->AddMessageListener(aName);
NS_ENSURE_TRUE(mViewParent, );
unused << mViewParent->SendAddMessageListener(nsDependentCString(aName));
}

void
EmbedLiteView::RemoveMessageListener(const char* aName)
{
LOGT("name:%s", aName);
NS_ENSURE_TRUE(mViewImpl, );
mViewImpl->RemoveMessageListener(aName);
NS_ENSURE_TRUE(mViewParent, );
unused << mViewParent->SendRemoveMessageListener(nsDependentCString(aName));
}

void EmbedLiteView::AddMessageListeners(const nsTArray<nsString>& aMessageNames)
{
NS_ENSURE_TRUE(mViewImpl, );
mViewImpl->AddMessageListeners(aMessageNames);
NS_ENSURE_TRUE(mViewParent, );
unused << mViewParent->SendAddMessageListeners(aMessageNames);
}

void EmbedLiteView::RemoveMessageListeners(const nsTArray<nsString>& aMessageNames)
{
NS_ENSURE_TRUE(mViewImpl, );
mViewImpl->RemoveMessageListeners(aMessageNames);
NS_ENSURE_TRUE(mViewParent, );
unused << mViewParent->SendRemoveMessageListeners(aMessageNames);
}

void
EmbedLiteView::SendAsyncMessage(const char16_t* aMessageName, const char16_t* aMessage)
{
NS_ENSURE_TRUE(mViewImpl, );
mViewImpl->DoSendAsyncMessage(aMessageName, aMessage);
NS_ENSURE_TRUE(mViewParent, );

const nsDependentString msgname(aMessageName);
const nsDependentString msg(aMessage);
unused << mViewParent->SendAsyncMessage(msgname, msg);
}

// Render interface
Expand Down Expand Up @@ -289,13 +295,6 @@ EmbedLiteView::SetGLViewPortSize(int width, int height)
mViewImpl->SetGLViewPortSize(width, height);
}

void
EmbedLiteView::ScheduleRender()
{
NS_ENSURE_TRUE(mViewImpl, );
mViewImpl->ScheduleRender();
}

void
EmbedLiteView::SuspendRendering()
{
Expand Down
7 changes: 4 additions & 3 deletions embedding/embedlite/EmbedLiteView.h
Expand Up @@ -17,6 +17,8 @@ class EmbedLiteViewIface;
namespace mozilla {
namespace embedlite {

class EmbedLiteViewThreadParent;
class PEmbedLiteViewParent;
class EmbedLiteView;

class EmbedLiteViewListener
Expand Down Expand Up @@ -112,8 +114,6 @@ class EmbedLiteView
// Setup renderable GL/EGL window surface size
virtual void SetGLViewPortSize(int width, int height);

virtual void ScheduleRender();

// Scripting Interface, allow to extend embedding API by creating
// child js scripts and messaging interface.
// and do communication between UI and Content child via json messages.
Expand All @@ -137,12 +137,13 @@ class EmbedLiteView
private:
friend class EmbedLiteViewThreadParent;
friend class EmbedLiteCompositorParent;
void SetImpl(EmbedLiteViewIface*);
void SetImpl(EmbedLiteViewThreadParent*);
EmbedLiteViewIface* GetImpl();

EmbedLiteApp* mApp;
EmbedLiteViewListener* mListener;
EmbedLiteViewIface* mViewImpl;
PEmbedLiteViewParent* mViewParent;
uint32_t mUniqueID;
uint32_t mParent;
};
Expand Down
16 changes: 0 additions & 16 deletions embedding/embedlite/embedhelpers/EmbedLiteViewIface.idl
Expand Up @@ -27,25 +27,9 @@ class nsString;
[scriptable, uuid(6d7750f8-e028-4445-a0cb-d9ce28fb03dd)]
interface EmbedLiteViewIface
{
void LoadURL(in string aName);
void GoBack();
void GoForward();
void StopLoad();
void Reload(in boolean aHardReload);
void LoadFrameScript(in string aURI);
void DoSendAsyncMessage([const] in wstring aMessageName,[const] in wstring aMessage);
void AddMessageListener(in string aMessageName);
void RemoveMessageListener(in string aMessageName);
void AddMessageListeners([const] in nsStringTArrayRef aNames);
void RemoveMessageListeners([const] in nsStringTArrayRef aNames);
void RenderToImage(in buffer aData, in int32_t aWidth, in int32_t aHeigth, in int32_t aStride, in int32_t aDepth);
void SetIsActive(in boolean isActive);
void SetIsFocused(in boolean isFocused);
void SuspendTimeouts();
void ResumeTimeouts();
void SetViewSize(in int32_t aWidth, in int32_t aHeight);
void SetGLViewPortSize(in int32_t aWidth, in int32_t aHeight);
void ScheduleRender();
void ReceiveInputEvent([const] in InputData aEvent);
void TextEvent(in string aComposite, in string aPreEdit);
void SendKeyPress(in int32_t aDomKeyCode, in int32_t aModifiers, in int32_t aCharCode);
Expand Down

0 comments on commit 119abc8

Please sign in to comment.