Backing out 1a916e3c1ad1
authorDoug Turner <dougt@dougt.org>
Sat, 26 Jun 2010 00:31:31 -0700
changeset 46270 9ff7137e6aa4254401da03f28149804794e6bf6f
parent 46269 cbe522c270609027eccf422c8be1803ca20bd594
child 46271 fae5d6bd9c533d17fb0e40990381be3de3a47006
push idunknown
push userunknown
push dateunknown
milestone1.9.3a6pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backing out 1a916e3c1ad1
docshell/base/IHistory.h
docshell/base/nsDocShell.cpp
toolkit/components/places/src/History.cpp
toolkit/components/places/src/History.h
toolkit/components/places/src/nsNavHistory.cpp
toolkit/components/places/src/nsNavHistory.h
toolkit/components/places/tests/browser/Makefile.in
--- a/docshell/base/IHistory.h
+++ b/docshell/base/IHistory.h
@@ -38,17 +38,16 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef mozilla_IHistory_h_
 #define mozilla_IHistory_h_
 
 #include "nsISupports.h"
 
 class nsIURI;
-class nsString;
 
 namespace mozilla {
 
     namespace dom {
         class Link;
     }
 
 #define IHISTORY_IID \
@@ -124,37 +123,24 @@ public:
      * @param aFlags
      *        The VisitFlags describing this visit.
      */
     NS_IMETHOD VisitURI(
         nsIURI *aURI,
         nsIURI *aLastVisitedURI,
         PRUint32 aFlags
     ) = 0;
-
-    /**
-     * Set the title of the URI.
-     *
-     * @pre aURI must not be null.
-     *
-     * @param aURI
-     *        The URI to set the title for.
-     * @param aTitle
-     *        The title string.
-     */
-    NS_IMETHOD SetURITitle(nsIURI* aURI, const nsString& aTitle) = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(IHistory, IHISTORY_IID)
 
 #define NS_DECL_IHISTORY \
     NS_IMETHOD RegisterVisitedCallback(nsIURI *aURI, \
                                        mozilla::dom::Link *aContent); \
     NS_IMETHOD UnregisterVisitedCallback(nsIURI *aURI, \
                                          mozilla::dom::Link *aContent); \
     NS_IMETHOD VisitURI(nsIURI *aURI, \
                         nsIURI *aLastVisitedURI, \
-                        PRUint32 aFlags); \
-    NS_IMETHOD SetURITitle(nsIURI* aURI, const nsString& aTitle);
+                        PRUint32 aFlags);
 
 } // namespace mozilla
 
 #endif // mozilla_IHistory_h_
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -4689,25 +4689,20 @@ nsDocShell::SetTitle(const PRUnichar * a
     // tree owner.
     if (!parent) {
         nsCOMPtr<nsIBaseWindow>
             treeOwnerAsWin(do_QueryInterface(mTreeOwner));
         if (treeOwnerAsWin)
             treeOwnerAsWin->SetTitle(aTitle);
     }
 
-    if (mCurrentURI && mLoadType != LOAD_ERROR_PAGE) {
-        nsCOMPtr<IHistory> history = services::GetHistoryService();
-        if (history) {
-            history->SetURITitle(mCurrentURI, nsString(mTitle));
-        }
-        else if (mGlobalHistory) {
-            mGlobalHistory->SetPageTitle(mCurrentURI, nsString(mTitle));
-        }
-    }
+    if (mGlobalHistory && mCurrentURI && mLoadType != LOAD_ERROR_PAGE) {
+        mGlobalHistory->SetPageTitle(mCurrentURI, nsString(mTitle));
+    }
+
 
     // Update SessionHistory with the document's title.
     if (mOSHE && mLoadType != LOAD_BYPASS_HISTORY &&
         mLoadType != LOAD_ERROR_PAGE) {
 
         mOSHE->SetTitle(mTitle);    
     }
 
--- a/toolkit/components/places/src/History.cpp
+++ b/toolkit/components/places/src/History.cpp
@@ -300,17 +300,17 @@ public:
       );
       NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Could not update frecency");
 
       // Notify nsNavHistory observers of visit, but only for certain types of
       // visits to maintain consistency with nsNavHistory::GetQueryResults.
       if (!mData->hidden &&
           mData->transitionType != nsINavHistoryService::TRANSITION_EMBED &&
           mData->transitionType != nsINavHistoryService::TRANSITION_FRAMED_LINK) {
-        history->NotifyOnVisit(mData->uri, visitId, mData->dateTime,
+        history->FireOnVisit(mData->uri, visitId, mData->dateTime,
                              mData->sessionId, mData->lastVisitId,
                              mData->transitionType);
       }
     }
 
     nsCOMPtr<nsIObserverService> obsService =
       mozilla::services::GetObserverService();
     if (obsService) {
@@ -691,163 +691,16 @@ public:
 protected:
   nsAutoPtr<VisitURIData> mData;
 };
 NS_IMPL_ISUPPORTS1(
   StartVisitURIStep
 , Step
 )
 
-////////////////////////////////////////////////////////////////////////////////
-//// Steps for SetURITitle
-
-struct SetTitleData : public FailSafeFinishTask
-{
-  nsCOMPtr<nsIURI> uri;
-  nsString title;
-};
-
-/**
- * Step 3: Notify that title has been updated.
- */
-class TitleNotifyStep: public Step
-{
-public:
-  NS_DECL_ISUPPORTS
-
-  TitleNotifyStep(nsAutoPtr<SetTitleData> aData)
-  : mData(aData)
-  {
-  }
-
-  NS_IMETHOD Callback(mozIStorageResultSet* aResultSet)
-  {
-    nsNavHistory* history = nsNavHistory::GetHistoryService();
-    history->NotifyTitleChange(mData->uri, mData->title);
-
-    return NS_OK;
-  }
-
-protected:
-  nsAutoPtr<SetTitleData> mData;
-};
-NS_IMPL_ISUPPORTS1(
-  TitleNotifyStep
-, mozIStorageStatementCallback
-)
-
-/**
- * Step 2: Set title.
- */
-class SetTitleStep : public Step
-{
-public:
-  NS_DECL_ISUPPORTS
-
-  SetTitleStep(nsAutoPtr<SetTitleData> aData)
-  : mData(aData)
-  {
-  }
-
-  NS_IMETHOD Callback(mozIStorageResultSet* aResultSet)
-  {
-    if (!aResultSet)
-      // URI record was not found.
-      return NS_OK;
-
-    nsCOMPtr<mozIStorageRow> row;
-    nsresult rv = aResultSet->GetNextRow(getter_AddRefs(row));
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    nsAutoString title;
-    rv = row->GetString(2, title);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    // It is actually common to set the title to be the same thing it used to
-    // be. For example, going to any web page will always cause a title to be set,
-    // even though it will often be unchanged since the last visit. In these
-    // cases, we can avoid DB writing and observer overhead.
-    if (mData->title.Equals(title) || (mData->title.IsVoid() && title.IsVoid()))
-      return NS_OK;
-
-    nsNavHistory* history = nsNavHistory::GetHistoryService();
-
-    nsCOMPtr<mozIStorageStatement> stmt =
-      history->GetStatementById(DB_SET_PLACE_TITLE);
-    NS_ENSURE_STATE(stmt);
-
-    if (mData->title.IsVoid()) {
-      rv = stmt->BindNullByName(NS_LITERAL_CSTRING("page_title"));
-    }
-    else {
-      rv = stmt->BindStringByName(
-        NS_LITERAL_CSTRING("page_title"),
-        StringHead(mData->title, TITLE_LENGTH_MAX)
-      );
-    }
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    rv = URIBinder::Bind(stmt, NS_LITERAL_CSTRING("page_url"), mData->uri);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    nsCOMPtr<Step> step = new TitleNotifyStep(mData);
-    rv = step->ExecuteAsync(stmt);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    return NS_OK;
-  }
-
-protected:
-  nsAutoPtr<SetTitleData> mData;
-};
-NS_IMPL_ISUPPORTS1(
-  SetTitleStep
-, mozIStorageStatementCallback
-)
-
-/**
- * Step 1: See if there is an existing URI.
- */
-class StartSetURITitleStep : public Step
-{
-public:
-  NS_DECL_ISUPPORTS
-
-  StartSetURITitleStep(nsAutoPtr<SetTitleData> aData)
-  : mData(aData)
-  {
-  }
-
-  NS_IMETHOD Callback(mozIStorageResultSet* aResultSet)
-  {
-    nsNavHistory* history = nsNavHistory::GetHistoryService();
-
-    // Find existing entry in moz_places table, if any.
-    nsCOMPtr<mozIStorageStatement> stmt =
-      history->GetStatementById(DB_GET_URL_PAGE_INFO);
-    NS_ENSURE_STATE(stmt);
-
-    nsresult rv = URIBinder::Bind(stmt, NS_LITERAL_CSTRING("page_url"), mData->uri);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    nsCOMPtr<Step> step = new SetTitleStep(mData);
-    rv = step->ExecuteAsync(stmt);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    return NS_OK;
-  }
-
-protected:
-  nsAutoPtr<SetTitleData> mData;
-};
-NS_IMPL_ISUPPORTS1(
-  StartSetURITitleStep
-, Step
-)
-
 } // anonymous namespace
 
 ////////////////////////////////////////////////////////////////////////////////
 //// History
 
 History* History::gService = NULL;
 
 History::History()
@@ -1123,46 +976,16 @@ History::UnregisterVisitedCallback(nsIUR
   // If the array is now empty, we should remove it from the hashtable.
   if (observers.IsEmpty()) {
     mObservers.RemoveEntry(aURI);
   }
 
   return NS_OK;
 }
 
-NS_IMETHODIMP
-History::SetURITitle(nsIURI* aURI, const nsString& aTitle)
-{
-  NS_PRECONDITION(aURI, "Must pass a non-null URI!");
-
-  nsNavHistory* history = nsNavHistory::GetHistoryService();
-  PRBool canAdd;
-  nsresult rv = history->CanAddURI(aURI, &canAdd);
-  NS_ENSURE_SUCCESS(rv, rv);
-  if (!canAdd) {
-    return NS_OK;
-  }
-
-  nsAutoPtr<SetTitleData> data(new SetTitleData());
-  data->uri = aURI;
-
-  if (aTitle.IsEmpty()) {
-    data->title.SetIsVoid(PR_TRUE);
-  }
-  else {
-    data->title.Assign(aTitle);
-  }
-
-  nsCOMPtr<Step> task(new StartSetURITitleStep(data));
-  AppendTask(task);
-
-  return NS_OK;
-}
- 
- 
 ////////////////////////////////////////////////////////////////////////////////
 //// nsISupports
 
 NS_IMPL_ISUPPORTS1(
   History
 , IHistory
 )
 
--- a/toolkit/components/places/src/History.h
+++ b/toolkit/components/places/src/History.h
@@ -47,17 +47,17 @@
 #include "nsURIHashKey.h"
 #include "nsTArray.h"
 #include "nsDeque.h"
 
 namespace mozilla {
 namespace places {
 
 #define NS_HISTORYSERVICE_CID \
-  {0x0937a705, 0x91a6, 0x417a, {0x82, 0x92, 0xb2, 0x2e, 0xb1, 0x0d, 0xa8, 0x6c}}
+  {0x9fc91e65, 0x1475, 0x4353, {0x9b, 0x9a, 0x93, 0xd7, 0x6f, 0x5b, 0xd9, 0xb7}}
 
 class History : public IHistory
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_IHISTORY
 
   History();
--- a/toolkit/components/places/src/nsNavHistory.cpp
+++ b/toolkit/components/places/src/nsNavHistory.cpp
@@ -2168,37 +2168,30 @@ nsNavHistory::GetNewSessionID()
   else
     mLastSessionID = 1;
 
   return mLastSessionID;
 }
 
 
 void
-nsNavHistory::NotifyOnVisit(nsIURI* aURI,
-                            PRInt64 aVisitID,
-                            PRTime aTime,
-                            PRInt64 aSessionID,
-                            PRInt64 referringVisitID,
-                            PRInt32 aTransitionType)
+nsNavHistory::FireOnVisit(nsIURI* aURI,
+                          PRInt64 aVisitID,
+                          PRTime aTime,
+                          PRInt64 aSessionID,
+                          PRInt64 referringVisitID,
+                          PRInt32 aTransitionType)
 {
   PRUint32 added = 0;
   NOTIFY_OBSERVERS(mCanNotify, mCacheObservers, mObservers,
                    nsINavHistoryObserver,
                    OnVisit(aURI, aVisitID, aTime, aSessionID,
                            referringVisitID, aTransitionType, &added));
 }
 
-void
-nsNavHistory::NotifyTitleChange(nsIURI* aURI, const nsString& aTitle)
-{
-  NOTIFY_OBSERVERS(mCanNotify, mCacheObservers, mObservers,
-                   nsINavHistoryObserver, OnTitleChanged(aURI, aTitle));
-}
-
 
 PRInt32
 nsNavHistory::GetDaysOfHistory() {
   PRInt32 daysOfHistory = 0;
   nsCOMPtr<mozIStorageStatement> statement;
   nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
       "SELECT ROUND(( "
         "strftime('%s','now','localtime','utc') - "
@@ -7360,16 +7353,17 @@ nsNavHistory::SetPageTitleInternal(nsIUR
 
   // url
   rv = URIBinder::Bind(mDBSetPlaceTitle, NS_LITERAL_CSTRING("page_url"), aURI);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = mDBSetPlaceTitle->Execute();
   NS_ENSURE_SUCCESS(rv, rv);
 
+  // observers (have to check first if it's bookmarked)
   NOTIFY_OBSERVERS(mCanNotify, mCacheObservers, mObservers,
                    nsINavHistoryObserver, OnTitleChanged(aURI, aTitle));
 
   return NS_OK;
 }
 
 nsresult
 nsNavHistory::AddPageWithVisits(nsIURI *aURI,
--- a/toolkit/components/places/src/nsNavHistory.h
+++ b/toolkit/components/places/src/nsNavHistory.h
@@ -116,18 +116,16 @@ namespace places {
     DB_GET_PAGE_INFO_BY_URL = 0
   , DB_GET_TAGS = 1
   , DB_IS_PAGE_VISITED = 2
   , DB_INSERT_VISIT = 3
   , DB_RECENT_VISIT_OF_URL = 4
   , DB_GET_PAGE_VISIT_STATS = 5
   , DB_UPDATE_PAGE_VISIT_STATS = 6
   , DB_ADD_NEW_PAGE = 7
-  , DB_GET_URL_PAGE_INFO = 8
-  , DB_SET_PLACE_TITLE = 9
   };
 
 } // namespace places
 } // namespace mozilla
 
 
 class mozIAnnotationService;
 class nsNavHistory;
@@ -435,41 +433,32 @@ public:
       case DB_RECENT_VISIT_OF_URL:
         return mDBRecentVisitOfURL;
       case DB_GET_PAGE_VISIT_STATS:
         return mDBGetPageVisitStats;
       case DB_UPDATE_PAGE_VISIT_STATS:
         return mDBUpdatePageVisitStats;
       case DB_ADD_NEW_PAGE:
         return mDBAddNewPage;
-      case DB_GET_URL_PAGE_INFO:
-        return mDBGetURLPageInfo;
-      case DB_SET_PLACE_TITLE:
-        return mDBSetPlaceTitle;
     }
     return nsnull;
   }
 
   PRInt64 GetNewSessionID();
 
   /**
    * Fires onVisit event to nsINavHistoryService observers
    */
-  void NotifyOnVisit(nsIURI* aURI,
+  void FireOnVisit(nsIURI* aURI,
                    PRInt64 aVisitID,
                    PRTime aTime,
                    PRInt64 aSessionID,
                    PRInt64 referringVisitID,
                    PRInt32 aTransitionType);
 
-  /**
-   * Fires onTitleChanged event to nsINavHistoryService observers
-   */
-  void NotifyTitleChange(nsIURI* aURI, const nsString& title);
-
 private:
   ~nsNavHistory();
 
   // used by GetHistoryService
   static nsNavHistory *gHistoryService;
 
 protected:
 
--- a/toolkit/components/places/tests/browser/Makefile.in
+++ b/toolkit/components/places/tests/browser/Makefile.in
@@ -43,33 +43,30 @@ VPATH		= @srcdir@
 relativesrcdir  = toolkit/components/places/tests/browser
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _BROWSER_FILES = \
 	browser_bug399606.js \
 	browser_visituri.js \
-	browser_settitle.js \
 	$(NULL)
 
 # These are files that need to be loaded via the HTTP proxy server
 # Access them through http://example.com/
 _HTTP_FILES = \
 	bug_399606/399606-httprefresh.html \
 	bug_399606/399606-location.reload.html \
 	bug_399606/399606-location.replace.html \
 	bug_399606/399606-window.location.href.html \
 	bug_399606/399606-window.location.html \
 	bug_399606/399606-history.go-0.html \
 	visituri/begin.html \
 	visituri/redirect_twice.sjs \
 	visituri/redirect_once.sjs \
 	visituri/final.html \
-	settitle/title1.html \
-	settitle/title2.html \
 	$(NULL)
 
 libs:: $(_BROWSER_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)
 
 libs:: $(_HTTP_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)