LCOV - code coverage report
Current view: directory - hal - WindowIdentifier.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 33 0 0.0 %
Date: 2012-06-02 Functions: 9 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* vim: set sw=2 ts=8 et ft=cpp : */
       3                 : /* ***** BEGIN LICENSE BLOCK *****
       4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       5                 :  *
       6                 :  * The contents of this file are subject to the Mozilla Public License Version
       7                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       8                 :  * the License. You may obtain a copy of the License at:
       9                 :  * http://www.mozilla.org/MPL/
      10                 :  *
      11                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      12                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      13                 :  * for the specific language governing rights and limitations under the
      14                 :  * License.
      15                 :  *
      16                 :  * The Original Code is Mozilla Code.
      17                 :  *
      18                 :  * The Initial Developer of the Original Code is
      19                 :  *   The Mozilla Foundation
      20                 :  * Portions created by the Initial Developer are Copyright (C) 2011
      21                 :  * the Initial Developer. All Rights Reserved.
      22                 :  *
      23                 :  * Contributor(s):
      24                 :  *   Justin Lebar <justin.lebar@gmail.com>
      25                 :  *
      26                 :  * Alternatively, the contents of this file may be used under the terms of
      27                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      28                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      29                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      30                 :  * of those above. If you wish to allow use of your version of this file only
      31                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      32                 :  * use your version of this file under the terms of the MPL, indicate your
      33                 :  * decision by deleting the provisions above and replace them with the notice
      34                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      35                 :  * the provisions above, a recipient may use your version of this file under
      36                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      37                 :  *
      38                 :  * ***** END LICENSE BLOCK ***** */
      39                 : 
      40                 : #include "mozilla/dom/ContentChild.h"
      41                 : #include "WindowIdentifier.h"
      42                 : #include "nsPIDOMWindow.h"
      43                 : 
      44                 : namespace mozilla {
      45                 : namespace hal {
      46                 : 
      47               0 : WindowIdentifier::WindowIdentifier()
      48                 :   : mWindow(nsnull)
      49               0 :   , mIsEmpty(true)
      50                 : {
      51               0 : }
      52                 : 
      53               0 : WindowIdentifier::WindowIdentifier(nsIDOMWindow *window)
      54                 :   : mWindow(window)
      55               0 :   , mIsEmpty(false)
      56                 : {
      57               0 :   mID.AppendElement(GetWindowID());
      58               0 : }
      59                 : 
      60               0 : WindowIdentifier::WindowIdentifier(const nsTArray<uint64> &id, nsIDOMWindow *window)
      61                 :   : mID(id)
      62                 :   , mWindow(window)
      63               0 :   , mIsEmpty(false)
      64                 : {
      65               0 :   mID.AppendElement(GetWindowID());
      66               0 : }
      67                 : 
      68               0 : WindowIdentifier::WindowIdentifier(const WindowIdentifier &other)
      69                 :   : mID(other.mID)
      70                 :   , mWindow(other.mWindow)
      71               0 :   , mIsEmpty(other.mIsEmpty)
      72                 : {
      73               0 : }
      74                 : 
      75                 : const InfallibleTArray<uint64>&
      76               0 : WindowIdentifier::AsArray() const
      77                 : {
      78               0 :   MOZ_ASSERT(!mIsEmpty);
      79               0 :   return mID;
      80                 : }
      81                 : 
      82                 : bool
      83               0 : WindowIdentifier::HasTraveledThroughIPC() const
      84                 : {
      85               0 :   MOZ_ASSERT(!mIsEmpty);
      86               0 :   return mID.Length() >= 2;
      87                 : }
      88                 : 
      89                 : void
      90               0 : WindowIdentifier::AppendProcessID()
      91                 : {
      92               0 :   MOZ_ASSERT(!mIsEmpty);
      93               0 :   mID.AppendElement(dom::ContentChild::GetSingleton()->GetID());
      94               0 : }
      95                 : 
      96                 : uint64
      97               0 : WindowIdentifier::GetWindowID() const
      98                 : {
      99               0 :   MOZ_ASSERT(!mIsEmpty);
     100               0 :   nsCOMPtr<nsPIDOMWindow> pidomWindow = do_QueryInterface(mWindow);
     101               0 :   if (!pidomWindow) {
     102               0 :     return uint64(-1);
     103                 :   }
     104               0 :   return pidomWindow->WindowID();
     105                 : }
     106                 : 
     107                 : nsIDOMWindow*
     108               0 : WindowIdentifier::GetWindow() const
     109                 : {
     110               0 :   MOZ_ASSERT(!mIsEmpty);
     111               0 :   return mWindow;
     112                 : }
     113                 : 
     114                 : } // namespace hal
     115                 : } // namespace mozilla

Generated by: LCOV version 1.7